From ecfc257f91bc7490054109771451cd89cf3eeaa9 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 1 Nov 2023 17:38:13 +0000 Subject: [PATCH] Simplify loading emoji data --- src/platform/polyfills.web.ts | 9 --------- .../com/composer/text-input/web/EmojiPicker.web.tsx | 5 +++-- .../com/composer/text-input/web/EmojiPickerData.json | 0 web/static/js/emoji-mart-data.js | 11 ----------- 4 files changed, 3 insertions(+), 22 deletions(-) rename bskyweb/static/emojis.2023.json => src/view/com/composer/text-input/web/EmojiPickerData.json (100%) delete mode 100644 web/static/js/emoji-mart-data.js diff --git a/src/platform/polyfills.web.ts b/src/platform/polyfills.web.ts index acd8fd9ecc..0b4a282835 100644 --- a/src/platform/polyfills.web.ts +++ b/src/platform/polyfills.web.ts @@ -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) -} diff --git a/src/view/com/composer/text-input/web/EmojiPicker.web.tsx b/src/view/com/composer/text-input/web/EmojiPicker.web.tsx index bfd3b9c6e9..4031afdaad 100644 --- a/src/view/com/composer/text-input/web/EmojiPicker.web.tsx +++ b/src/view/com/composer/text-input/web/EmojiPicker.web.tsx @@ -72,8 +72,9 @@ export function EmojiPicker({close}: {close: () => void}) { }, ]}> { + return (await import('./EmojiPickerData.json')).default + }} onEmojiSelect={onInsert} autoFocus={false} /> diff --git a/bskyweb/static/emojis.2023.json b/src/view/com/composer/text-input/web/EmojiPickerData.json similarity index 100% rename from bskyweb/static/emojis.2023.json rename to src/view/com/composer/text-input/web/EmojiPickerData.json diff --git a/web/static/js/emoji-mart-data.js b/web/static/js/emoji-mart-data.js deleted file mode 100644 index 5127e2dd2f..0000000000 --- a/web/static/js/emoji-mart-data.js +++ /dev/null @@ -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()