Simplify loading emoji data (#1790)
parent
9fb20517ae
commit
f9944b55e2
|
@ -6,12 +6,3 @@ findLast.shim()
|
||||||
|
|
||||||
// @ts-ignore whatever typescript wants to complain about here, I dont care about -prf
|
// @ts-ignore whatever typescript wants to complain about here, I dont care about -prf
|
||||||
window.setImmediate = (cb: () => void) => setTimeout(cb, 0)
|
window.setImmediate = (cb: () => void) => setTimeout(cb, 0)
|
||||||
|
|
||||||
// @ts-ignore not on the TS signature due to bad support -prf
|
|
||||||
if (!globalThis.Intl?.Segmenter) {
|
|
||||||
// loading emoji mart data
|
|
||||||
// TODO: This condition doesn't make sense; emojimart has nothing to do with Intl.
|
|
||||||
const emojiMartScript = document.createElement('script')
|
|
||||||
emojiMartScript.setAttribute('src', '/static/js/emoji-mart-data.js')
|
|
||||||
document.head.appendChild(emojiMartScript)
|
|
||||||
}
|
|
||||||
|
|
|
@ -72,8 +72,9 @@ export function EmojiPicker({close}: {close: () => void}) {
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
<Picker
|
<Picker
|
||||||
// @ts-ignore we set emojiMartData in `emoji-mart-data.js` file
|
data={async () => {
|
||||||
data={window.emojiMartData}
|
return (await import('./EmojiPickerData.json')).default
|
||||||
|
}}
|
||||||
onEmojiSelect={onInsert}
|
onEmojiSelect={onInsert}
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
async function grabEmojiData() {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/static/emojis.2023.json')
|
|
||||||
const emojiMartData = await response.json()
|
|
||||||
window.emojiMartData = emojiMartData
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(`Failed to load emojis`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grabEmojiData()
|
|
Loading…
Reference in New Issue