Group emojis only by pack and remove pack: prefix

Ref: grouped-emoji-picker
This commit is contained in:
Tusooa Zhu 2021-10-08 15:30:55 -04:00
parent 3156f046b4
commit d648a6f8dc
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
1 changed files with 7 additions and 1 deletions

View File

@ -116,9 +116,15 @@ const instance = {
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}) .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
}, },
groupedCustomEmojis (state) { groupedCustomEmojis (state) {
const packsOf = emoji => {
return emoji.tags
.filter(k => k.startsWith('pack:'))
.map(k => k.slice(5)) // remove 'pack:' prefix
}
return state.customEmoji return state.customEmoji
.reduce((res, emoji) => { .reduce((res, emoji) => {
emoji.tags.forEach(packName => { packsOf(emoji).forEach(packName => {
const packId = `custom-${packName}` const packId = `custom-${packName}`
if (!res[packId]) { if (!res[packId]) {
res[packId] = ({ res[packId] = ({