From ca2acf3cff6203e9e53789227b67b48f3a90fb02 Mon Sep 17 00:00:00 2001 From: matty Date: Mon, 23 Mar 2026 01:34:05 +0000 Subject: [PATCH] jack off backwards with mine preanits --- .../emoji/components/emoji-picker.tsx | 14 +------ packages/nicolium/src/service-worker/sw.ts | 39 +++++++++++++------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/packages/nicolium/src/features/emoji/components/emoji-picker.tsx b/packages/nicolium/src/features/emoji/components/emoji-picker.tsx index 74ea3e323..39c8a45a7 100644 --- a/packages/nicolium/src/features/emoji/components/emoji-picker.tsx +++ b/packages/nicolium/src/features/emoji/components/emoji-picker.tsx @@ -11,24 +11,12 @@ const getSpritesheetURL = () => spritesheetURL; const getImageURL = (set: string, name: string) => joinPublicPath(`/packs/emoji/${name}.svg`); const Picker: React.FC = (props) => { - const ref = useRef(null); + const ref = useRef(null); useEffect(() => { const input = { ...props, data, ref, autoFocus: true, getImageURL, getSpritesheetURL }; new EmojiPicker(input); - - // Force a reflow on the shadow DOM scroll container so unicode emojis - // render immediately on mobile instead of waiting for user interaction. - requestAnimationFrame(() => { - const picker = ref.current?.querySelector('em-emoji-picker'); - const scrollable = picker?.shadowRoot?.querySelector('.scroll'); - if (scrollable) { - (scrollable as HTMLElement).style.overflow = 'hidden'; - void (scrollable as HTMLElement).offsetHeight; - (scrollable as HTMLElement).style.overflow = ''; - } - }); }, []); return
; diff --git a/packages/nicolium/src/service-worker/sw.ts b/packages/nicolium/src/service-worker/sw.ts index a69fdc8b2..738d27e3c 100644 --- a/packages/nicolium/src/service-worker/sw.ts +++ b/packages/nicolium/src/service-worker/sw.ts @@ -328,7 +328,7 @@ const handleNotificationClick = (event: NotificationEvent) => { // --- Asset caching --- -const CACHE_NAME = 'ncd-assets-v1'; +const CACHE_NAME = 'ncd-assets-v2'; /** URL patterns to cache with a cache-first strategy. */ const CACHEABLE_PATTERNS = [ @@ -341,24 +341,38 @@ const CACHEABLE_PATTERNS = [ const isCacheable = (url: string): boolean => CACHEABLE_PATTERNS.some((pattern) => pattern.test(url)); -/** Cache-first fetch handler for static assets. */ +/** Cache-first fetch handler for static assets. Falls back to network on any error. */ const handleFetch = (event: FetchEvent) => { const { request } = event; if (request.method !== 'GET' || !isCacheable(request.url)) return; event.respondWith( - caches.match(request).then((cached) => { - if (cached) return cached; + caches + .match(request) + .then((cached) => { + if (cached) return cached; - return fetch(request).then((response) => { - if (response.ok) { - const clone = response.clone(); - caches.open(CACHE_NAME).then((cache) => cache.put(request, clone)); - } - return response; - }); - }), + return fetch(request).then((response) => { + if (response.ok && response.status === 200) { + const clone = response.clone(); + caches.open(CACHE_NAME).then((cache) => cache.put(request, clone)); + } + return response; + }); + }) + .catch(() => fetch(request)), + ); +}; + +/** Clean up old caches on activation. */ +const handleActivate = (event: ExtendableEvent) => { + event.waitUntil( + caches + .keys() + .then((keys) => + Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))), + ), ); }; @@ -366,3 +380,4 @@ const handleFetch = (event: FetchEvent) => { self.addEventListener('push', handlePush); self.addEventListener('notificationclick', handleNotificationClick); self.addEventListener('fetch', handleFetch); +self.addEventListener('activate', handleActivate);