Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoid recalculating custom emoji index #446

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading