Skip to content

Commit

Permalink
perf: avoid recalculating custom emoji index (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Sep 7, 2024
1 parent 9268c67 commit 0c09f56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/picker/components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,13 @@ export function createRoot (shadowRoot, props) {
function updateCustomEmoji () {
// Certain effects have an implicit dependency on customEmoji since it affects the database
// Getting it here on the state ensures this effect re-runs when customEmoji change.
// Setting it on the database is pointless but prevents this code from being removed by a minifier.
state.database.customEmoji = state.customEmoji || EMPTY_ARRAY
const { customEmoji, database } = state
const databaseCustomEmoji = customEmoji || EMPTY_ARRAY
if (database.customEmoji !== databaseCustomEmoji) {
// Avoid setting this if the customEmoji have _not_ changed, because the setter triggers a re-computation of the
// `customEmojiIndex`. Note we don't bother with deep object changes.
database.customEmoji = databaseCustomEmoji
}
}

createEffect(() => {
Expand Down

0 comments on commit 0c09f56

Please sign in to comment.