Simplify loading emoji data (#1790)

zio/stable
dan 2023-11-01 17:49:07 +00:00 committed by GitHub
parent 9fb20517ae
commit f9944b55e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 22 deletions

View File

@ -6,12 +6,3 @@ findLast.shim()
// @ts-ignore whatever typescript wants to complain about here, I dont care about -prf
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)
}

View File

@ -72,8 +72,9 @@ export function EmojiPicker({close}: {close: () => void}) {
},
]}>
<Picker
// @ts-ignore we set emojiMartData in `emoji-mart-data.js` file
data={window.emojiMartData}
data={async () => {
return (await import('./EmojiPickerData.json')).default
}}
onEmojiSelect={onInsert}
autoFocus={false}
/>

View File

@ -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()