1
0
Fork 0
forked from Mirrors/gomuks

web/emoji: allow custom emojis in frequently used

This commit is contained in:
Tulir Asokan 2024-10-27 13:05:41 +02:00
parent 808bdbc068
commit 21e2dcbc43
2 changed files with 12 additions and 5 deletions

View file

@ -127,9 +127,6 @@ export default class Client {
}
async incrementFrequentlyUsedEmoji(targetEmoji: string) {
if (targetEmoji.startsWith("mxc://")) {
return
}
let recentEmoji = this.store.accountData.get("io.element.recent_emoji")?.recent_emoji as
[string, number][] | undefined
if (!Array.isArray(recentEmoji)) {

View file

@ -199,7 +199,17 @@ export function useFilteredEmojis(query: string, params: useEmojisParams = {}):
}
return Array.from(params.frequentlyUsed.keys()
.map(key => {
const emoji = emojiMap.get(key)
let emoji: Emoji | undefined
if (key.startsWith("mxc://")) {
for (const pack of params.customEmojiPacks?.values() ?? []) {
emoji = pack.emojiMap.get(key)
if (emoji) {
break
}
}
} else {
emoji = emojiMap.get(key)
}
if (!emoji) {
return undefined
}
@ -207,7 +217,7 @@ export function useFilteredEmojis(query: string, params: useEmojisParams = {}):
})
.filter(emoji => emoji !== undefined))
.filter((_emoji, index) => index < 24)
}, [params.frequentlyUsed])
}, [params.frequentlyUsed, params.customEmojiPacks])
const prev = useRef<filteredEmojiCache>({
query: "",
result: [],