cache emoji groups etc

This commit is contained in:
Henry Jameson 2024-08-13 22:51:17 +03:00
parent 6bc020c733
commit c4352a1936

View file

@ -145,6 +145,10 @@ const defaultState = {
quotingAvailable: false, quotingAvailable: false,
groupActorAvailable: false, groupActorAvailable: false,
// Emoji stuff
standardEmojiList: null,
standardEmojiGroupList: null,
// Html stuff // Html stuff
instanceSpecificPanelContent: '', instanceSpecificPanelContent: '',
tos: '', tos: '',
@ -246,15 +250,21 @@ const instance = {
}, {}) }, {})
}, },
standardEmojiList (state) { standardEmojiList (state) {
return SORTED_EMOJI_GROUP_IDS if (!state.standardEmojiList) {
state.standardEmojiList = SORTED_EMOJI_GROUP_IDS
.map(groupId => (state.emoji[groupId] || []).map(k => injectAnnotations(k, state.unicodeEmojiAnnotations))) .map(groupId => (state.emoji[groupId] || []).map(k => injectAnnotations(k, state.unicodeEmojiAnnotations)))
.reduce((a, b) => a.concat(b), []) .reduce((a, b) => a.concat(b), [])
}
return state.standardEmojiList
}, },
standardEmojiGroupList (state) { standardEmojiGroupList (state) {
return SORTED_EMOJI_GROUP_IDS.map(groupId => ({ if (!state.standardEmojiGroupList) {
state.standardEmojiGroupList = SORTED_EMOJI_GROUP_IDS.map(groupId => ({
id: groupId, id: groupId,
emojis: (state.emoji[groupId] || []).map(k => injectAnnotations(k, state.unicodeEmojiAnnotations)) emojis: (state.emoji[groupId] || []).map(k => injectAnnotations(k, state.unicodeEmojiAnnotations))
})) }))
}
return state.standardEmojiGroupList
}, },
instanceDomain (state) { instanceDomain (state) {
return new URL(state.server).hostname return new URL(state.server).hostname