Emoji substring search (#39353)
This commit is contained in:
14 files changed
+169
-54
No files matched your search
@@ -1,31 +1,36 @@
|
||||
import debug from 'debug';
|
||||
|
||||
import { EMOJI_DB_NAME_SHORTCODES, EMOJI_TYPE_CUSTOM } from './constants';
|
||||
import {
|
||||
importCustomEmojiData,
|
||||
importEmojiData,
|
||||
importLegacyShortcodes,
|
||||
} from './loader';
|
||||
import type { EmojiWorkerMessage } from './types';
|
||||
|
||||
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);
|
||||
function handleMessage(event: MessageEvent<EmojiWorkerMessage>) {
|
||||
const { data } = event;
|
||||
if (data.type === 'debug') {
|
||||
debug.enable(data.debugValue);
|
||||
} else {
|
||||
void loadData(data.storeName);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData(locale: string) {
|
||||
async function loadData(storeName: string) {
|
||||
let importCount: number | undefined;
|
||||
if (locale === EMOJI_TYPE_CUSTOM) {
|
||||
if (storeName === EMOJI_TYPE_CUSTOM) {
|
||||
importCount = (await importCustomEmojiData())?.length;
|
||||
} else if (locale === EMOJI_DB_NAME_SHORTCODES) {
|
||||
} else if (storeName === EMOJI_DB_NAME_SHORTCODES) {
|
||||
importCount = (await importLegacyShortcodes())?.length;
|
||||
} else {
|
||||
importCount = (await importEmojiData(locale))?.length;
|
||||
importCount = (await importEmojiData(storeName))?.length;
|
||||
}
|
||||
|
||||
if (importCount) {
|
||||
self.postMessage(`loaded ${importCount} emojis into ${locale}`);
|
||||
self.postMessage(`loaded ${importCount} emojis into ${storeName}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user