also use emojiType as cache key for dynamic asset cache
This commit is contained in:
parent
16139c3bcc
commit
83ee9f7e4b
@ -37,12 +37,9 @@ const apis = {
|
|||||||
"https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/" + code.toLowerCase() + "_flat.svg",
|
"https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/" + code.toLowerCase() + "_flat.svg",
|
||||||
};
|
};
|
||||||
export type EmojiType = keyof typeof apis;
|
export type EmojiType = keyof typeof apis;
|
||||||
export function loadEmoji(code: string, type?: EmojiType) {
|
export function loadEmoji(code: string, type: EmojiType) {
|
||||||
// https://github.com/svgmoji/svgmoji
|
// https://github.com/svgmoji/svgmoji
|
||||||
if (!type || !apis[type]) {
|
const api = apis[type] ?? apis.twemoji;
|
||||||
type = "twemoji";
|
|
||||||
}
|
|
||||||
const api = apis[type];
|
|
||||||
if (typeof api === "function") {
|
if (typeof api === "function") {
|
||||||
return fetch(api(code));
|
return fetch(api(code));
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ const loadDynamicAsset = (emojiType: EmojiType = "twemoji") => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return async (...args: Parameters<typeof fn>) => {
|
return async (...args: Parameters<typeof fn>) => {
|
||||||
const cacheKey = JSON.stringify(args);
|
const cacheKey = JSON.stringify({ ...args, emojiType });
|
||||||
const cachedFont = assetCache.get(cacheKey);
|
const cachedFont = assetCache.get(cacheKey);
|
||||||
if (cachedFont) {
|
if (cachedFont) {
|
||||||
return cachedFont;
|
return cachedFont;
|
||||||
|
Loading…
Reference in New Issue
Block a user