mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Port changes from 1935f4db79 to glitch-soc
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ChaosExAnima <ChaosExAnima@users.noreply.github.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
29 lines
908 B
TypeScript
29 lines
908 B
TypeScript
import { EMOJI_DB_NAME_SHORTCODES, EMOJI_TYPE_CUSTOM } from './constants';
|
|
|
|
addEventListener('message', handleMessage);
|
|
self.postMessage('ready'); // After the worker is ready, notify the main thread
|
|
|
|
function handleMessage(event: MessageEvent<{ locale: string }>) {
|
|
const {
|
|
data: { locale },
|
|
} = event;
|
|
void loadData(locale);
|
|
}
|
|
|
|
async function loadData(locale: string) {
|
|
const { importCustomEmojiData, importEmojiData, importLegacyShortcodes } =
|
|
await import('./loader');
|
|
let importCount: number | undefined;
|
|
if (locale === EMOJI_TYPE_CUSTOM) {
|
|
importCount = (await importCustomEmojiData())?.length;
|
|
} else if (locale === EMOJI_DB_NAME_SHORTCODES) {
|
|
importCount = (await importLegacyShortcodes())?.length;
|
|
} else {
|
|
importCount = (await importEmojiData(locale))?.length;
|
|
}
|
|
|
|
if (importCount) {
|
|
self.postMessage(`loaded ${importCount} emojis into ${locale}`);
|
|
}
|
|
}
|