Emoji: Refresh custom emoji on new (#37271)
This commit is contained in:
7 files changed
+123
-32
No files matched your search
@@ -161,11 +161,26 @@ export async function putEmojiData(emojis: UnicodeEmojiData[], locale: Locale) {
|
||||
await trx.done;
|
||||
}
|
||||
|
||||
export async function putCustomEmojiData(emojis: CustomEmojiData[]) {
|
||||
export async function putCustomEmojiData({
|
||||
emojis,
|
||||
clear = false,
|
||||
}: {
|
||||
emojis: CustomEmojiData[];
|
||||
clear?: boolean;
|
||||
}) {
|
||||
const db = await loadDB();
|
||||
const trx = db.transaction('custom', 'readwrite');
|
||||
|
||||
// When importing from the API, clear everything first.
|
||||
if (clear) {
|
||||
await trx.store.clear();
|
||||
log('Cleared existing custom emojis in database');
|
||||
}
|
||||
|
||||
await Promise.all(emojis.map((emoji) => trx.store.put(emoji)));
|
||||
await trx.done;
|
||||
|
||||
log('Imported %d custom emojis into database', emojis.length);
|
||||
}
|
||||
|
||||
export async function putLegacyShortcodes(shortcodes: ShortcodesDataset) {
|
||||
@@ -188,6 +203,13 @@ export async function putLatestEtag(etag: string, localeString: string) {
|
||||
await db.put('etags', etag, locale);
|
||||
}
|
||||
|
||||
export async function clearEtag(localeString: string) {
|
||||
const locale = toSupportedLocaleOrCustom(localeString);
|
||||
const db = await loadDB();
|
||||
await db.delete('etags', locale);
|
||||
log('Cleared etag for %s', locale);
|
||||
}
|
||||
|
||||
export async function loadEmojiByHexcode(
|
||||
hexcode: string,
|
||||
localeString: string,
|
||||
|
||||
Reference in new issue
Block a user