Echo ce4b913792 [Glitch] Emoji: Cache data by path instead of just Etag
Port 3d0a6ba83128641ddd8d66ec539df9d52a7679e3 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2026-02-13 18:41:42 +01:00

23 lines
723 B
TypeScript

import type { ApiCustomEmojiJSON } from '@/flavours/glitch/api_types/custom_emoji';
import { loadCustomEmoji } from '@/flavours/glitch/features/emoji';
export async function importCustomEmoji(emojis: ApiCustomEmojiJSON[]) {
if (emojis.length === 0) {
return;
}
// First, check if we already have them all.
const { searchCustomEmojisByShortcodes, clearCache } =
await import('@/flavours/glitch/features/emoji/database');
const existingEmojis = await searchCustomEmojisByShortcodes(
emojis.map((emoji) => emoji.shortcode),
);
// If there's a mismatch, re-import all custom emojis.
if (existingEmojis.length < emojis.length) {
await clearCache('custom');
await loadCustomEmoji();
}
}