Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at cope-settings-sync 30 lines 965 B view raw
1import {useCallback} from 'react' 2import {init} from 'emoji-mart' 3 4/** 5 * Only load the emoji picker data once per page load. 6 */ 7let loadRequested = false 8 9/** 10 * Preloads emoji-mart data so the picker renders instantly when opened. 11 * 12 * Returns a function that can be called manually to trigger preloading (e.g. 13 * on hover). When `immediate` is `true`, preloading starts on mount. 14 * 15 * Data is only fetched once per page load — subsequent calls are no-ops. 16 * 17 * @see {@link https://github.com/missive/emoji-mart/blob/16978d04a766eec6455e2e8bb21cd8dc0b3c7436/README.md?plain=1#L194 | emoji-mart preloading docs} 18 */ 19export function useWebPreloadEmoji({immediate}: {immediate?: boolean} = {}) { 20 const preload = useCallback(async () => { 21 if (loadRequested) return 22 loadRequested = true 23 try { 24 const data = (await import('@emoji-mart/data')).default 25 init({data}) 26 } catch (e) {} 27 }, []) 28 if (immediate) preload() 29 return preload 30}