Echo 177d3c59d0 [Glitch] Emoji: Refresh custom emoji on new
Port 3d55dcdf7fbbebe3006ef86e765e9fc2455d34e1 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2025-12-17 18:34:02 +01:00

23 lines
721 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, clearEtag } =
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 clearEtag('custom');
await loadCustomEmoji();
}
}