Optimise emoji picker loading process

This commit is contained in:
Tusooa Zhu 2021-08-15 00:43:35 -04:00
commit 123913f34f
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 34 additions and 71 deletions

View file

@ -115,6 +115,24 @@ const instance = {
.map(key => [key, state[key]])
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
},
groupedCustomEmojis (state) {
return state.customEmoji
.reduce((res, emoji) => {
emoji.tags.forEach(packName => {
const packId = `custom-${packName}`
if (!res[packId]) {
res[packId] = ({
id: packId,
text: packName,
image: emoji.imageUrl,
emojis: []
})
}
res[packId].emojis.push(emoji)
})
return res
}, {})
},
instanceDomain (state) {
return new URL(state.server).hostname
}