make emoji tags reactive

This commit is contained in:
Hazelnoot 2025-10-23 01:54:36 -04:00
parent 1f45482cf2
commit 75ee2fb1a7

View file

@ -10,6 +10,15 @@ import { get, set } from '@/utility/idb-proxy.js';
const storageCache = await get('emojis');
export const customEmojis = shallowRef<Misskey.entities.EmojiSimple[]>(Array.isArray(storageCache) ? storageCache : []);
export const customEmojiTags = computed(() => {
const tags = new Set<string>();
for (const emoji of customEmojis.value) {
for (const tag of emoji.aliases) {
tags.add(tag);
}
}
return Array.from(tags);
});
export const customEmojiCategories = computed<[ ...string[], null ]>(() => {
const categories = new Set<string>();
for (const emoji of customEmojis.value) {
@ -60,17 +69,6 @@ export async function fetchCustomEmojis(force = false) {
set('lastEmojisFetchedAt', now);
}
let cachedTags;
export function getCustomEmojiTags() {
if (cachedTags) return cachedTags;
const tags = new Set();
for (const emoji of customEmojis.value) {
for (const tag of emoji.aliases) {
tags.add(tag);
}
}
const res = Array.from(tags);
cachedTags = res;
return res;
return customEmojiTags.value;
}