From e079cb9c2cbb586aae9f43f8299fc5ff5a70b292 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Sun, 6 Jul 2025 21:27:28 +0530 Subject: [PATCH 1/8] Update common.js --- components/nav/common.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index 0c6143fcd..998f51749 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -15,7 +15,7 @@ import { useServiceWorker } from '../serviceworker' import { signOut } from 'next-auth/react' import Badges from '../badge' import { randInRange } from '../../lib/rand' -import { useFireworks } from '../fireworks' +import { useLightning } from '../lightning' import LightningIcon from '../../svgs/bolt.svg' import SearchIcon from '../../svgs/search-line.svg' import classNames from 'classnames' @@ -121,8 +121,26 @@ export function NavSelect ({ sub: subName, className, size }) { export function NavNotifications ({ className }) { const hasNewNotes = useHasNewNotes() + // Dynamically update favicon to avoid browser caching issues (esp. Safari) + useEffect(() => { + const setFavicon = (href) => { + // Remove all existing favicon link tags + const links = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]') + links.forEach(link => link.parentNode.removeChild(link)) + // Create new favicon link with cache-busting query + const link = document.createElement('link') + link.rel = 'shortcut icon' + link.type = 'image/png' + // Add a cache-busting query string to force reload in Safari + link.href = href + '?v=' + Date.now() + document.head.appendChild(link) + } + setFavicon(hasNewNotes ? '/favicon-notify.png' : '/favicon.png') + }, [hasNewNotes]) + return ( <> + {/* fallback for SSR, but will be replaced on client by useEffect */} @@ -400,15 +418,13 @@ export function LoginButtons ({ handleClose }) { } export function AnonDropdown ({ path }) { - const strike = useFireworks() + const strike = useLightning() useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { - const striked = strike() - if (striked) { - window.localStorage.setItem('striked', 'yep') - } + strike() + window.localStorage.setItem('striked', 'yep') }, randInRange(3000, 10000)) return () => clearTimeout(to) } From 9ee4590e382ef1a3aaac3f39ec798ad9a51e647e Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Sun, 6 Jul 2025 21:44:49 +0530 Subject: [PATCH 2/8] Update common.js --- components/nav/common.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index 998f51749..415b1e719 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -15,7 +15,7 @@ import { useServiceWorker } from '../serviceworker' import { signOut } from 'next-auth/react' import Badges from '../badge' import { randInRange } from '../../lib/rand' -import { useLightning } from '../lightning' +import { useFireworks } from '../fireworks' import LightningIcon from '../../svgs/bolt.svg' import SearchIcon from '../../svgs/search-line.svg' import classNames from 'classnames' @@ -418,13 +418,15 @@ export function LoginButtons ({ handleClose }) { } export function AnonDropdown ({ path }) { - const strike = useLightning() + const strike = useFireworks() useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { - strike() - window.localStorage.setItem('striked', 'yep') + const striked = strike() + if (striked) { + window.localStorage.setItem('striked', 'yep') + } }, randInRange(3000, 10000)) return () => clearTimeout(to) } From a214c0cc74ee72d12e443233b7ad5e5d942a8da8 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 08:14:56 +0530 Subject: [PATCH 3/8] Update common.js --- components/nav/common.js | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index 415b1e719..dd6f3d0ef 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -15,7 +15,7 @@ import { useServiceWorker } from '../serviceworker' import { signOut } from 'next-auth/react' import Badges from '../badge' import { randInRange } from '../../lib/rand' -import { useFireworks } from '../fireworks' +import { useLightning } from '../lightning' import LightningIcon from '../../svgs/bolt.svg' import SearchIcon from '../../svgs/search-line.svg' import classNames from 'classnames' @@ -120,29 +120,19 @@ export function NavSelect ({ sub: subName, className, size }) { export function NavNotifications ({ className }) { const hasNewNotes = useHasNewNotes() + // Use a stateful cache-buster to force favicon reload + const [cacheBuster, setCacheBuster] = useState(Date.now()) - // Dynamically update favicon to avoid browser caching issues (esp. Safari) useEffect(() => { - const setFavicon = (href) => { - // Remove all existing favicon link tags - const links = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]') - links.forEach(link => link.parentNode.removeChild(link)) - // Create new favicon link with cache-busting query - const link = document.createElement('link') - link.rel = 'shortcut icon' - link.type = 'image/png' - // Add a cache-busting query string to force reload in Safari - link.href = href + '?v=' + Date.now() - document.head.appendChild(link) - } - setFavicon(hasNewNotes ? '/favicon-notify.png' : '/favicon.png') + setCacheBuster(Date.now()) }, [hasNewNotes]) + const faviconHref = (hasNewNotes ? '/favicon-notify.png' : '/favicon.png') + '?v=' + cacheBuster + return ( <> - {/* fallback for SSR, but will be replaced on client by useEffect */} - + @@ -418,15 +408,13 @@ export function LoginButtons ({ handleClose }) { } export function AnonDropdown ({ path }) { - const strike = useFireworks() + const strike = useLightning() useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { - const striked = strike() - if (striked) { - window.localStorage.setItem('striked', 'yep') - } + strike() + window.localStorage.setItem('striked', 'yep') }, randInRange(3000, 10000)) return () => clearTimeout(to) } From c0493076f39c380c14a4f4630170b3421bdc2a33 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 08:19:05 +0530 Subject: [PATCH 4/8] Update common.js --- components/nav/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index dd6f3d0ef..5232e7059 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -15,7 +15,7 @@ import { useServiceWorker } from '../serviceworker' import { signOut } from 'next-auth/react' import Badges from '../badge' import { randInRange } from '../../lib/rand' -import { useLightning } from '../lightning' +import { useFireworks } from '../fireworks' import LightningIcon from '../../svgs/bolt.svg' import SearchIcon from '../../svgs/search-line.svg' import classNames from 'classnames' @@ -408,7 +408,7 @@ export function LoginButtons ({ handleClose }) { } export function AnonDropdown ({ path }) { - const strike = useLightning() + const strike = useFireworks() useEffect(() => { if (!window.localStorage.getItem('striked')) { From be3eb239171711240a2a1ab9a3a366205511f53a Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 08:20:12 +0530 Subject: [PATCH 5/8] Update common.js --- components/nav/common.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index 5232e7059..ea3ca7be7 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -413,8 +413,10 @@ export function AnonDropdown ({ path }) { useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { - strike() - window.localStorage.setItem('striked', 'yep') + const striked = strike() + if (striked) { + window.localStorage.setItem('striked', 'yep') + } }, randInRange(3000, 10000)) return () => clearTimeout(to) } From 5184b6c9f1cada8a270ff748266959c293adaa62 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 18:37:34 +0530 Subject: [PATCH 6/8] Update common.js --- components/nav/common.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index ea3ca7be7..17cbde2e9 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -120,19 +120,27 @@ export function NavSelect ({ sub: subName, className, size }) { export function NavNotifications ({ className }) { const hasNewNotes = useHasNewNotes() - // Use a stateful cache-buster to force favicon reload - const [cacheBuster, setCacheBuster] = useState(Date.now()) useEffect(() => { - setCacheBuster(Date.now()) + const setFavicon = (href) => { + // Remove all existing favicon link tags + const links = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]') + links.forEach(link => link.parentNode.removeChild(link)) + // Create new favicon link with cache-busting query + const link = document.createElement('link') + link.rel = 'shortcut icon' + link.type = 'image/png' + link.href = href + '?v=' + Date.now() + document.head.appendChild(link) + } + setFavicon(hasNewNotes ? '/favicon-notify.png' : '/favicon.png') }, [hasNewNotes]) - const faviconHref = (hasNewNotes ? '/favicon-notify.png' : '/favicon.png') + '?v=' + cacheBuster - return ( <> + {/* fallback for SSR, but will be replaced on client by useEffect */} - + @@ -413,10 +421,8 @@ export function AnonDropdown ({ path }) { useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { - const striked = strike() - if (striked) { - window.localStorage.setItem('striked', 'yep') - } + strike() + window.localStorage.setItem('striked', 'yep') }, randInRange(3000, 10000)) return () => clearTimeout(to) } From 80748c7256be98f6fac206897999c82767eef218 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 18:39:58 +0530 Subject: [PATCH 7/8] Update common.js --- components/nav/common.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/nav/common.js b/components/nav/common.js index 17cbde2e9..e74bbc800 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -420,9 +420,10 @@ export function AnonDropdown ({ path }) { useEffect(() => { if (!window.localStorage.getItem('striked')) { - const to = setTimeout(() => { - strike() - window.localStorage.setItem('striked', 'yep') + const striked = strike() + if (striked) { + window.localStorage.setItem('striked', 'yep') + } }, randInRange(3000, 10000)) return () => clearTimeout(to) } From c2a47bc2897eff2d4688949f26540af922191710 Mon Sep 17 00:00:00 2001 From: Axel Vyrn Date: Mon, 7 Jul 2025 18:40:51 +0530 Subject: [PATCH 8/8] Update common.js --- components/nav/common.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/nav/common.js b/components/nav/common.js index e74bbc800..d07382ada 100644 --- a/components/nav/common.js +++ b/components/nav/common.js @@ -420,7 +420,8 @@ export function AnonDropdown ({ path }) { useEffect(() => { if (!window.localStorage.getItem('striked')) { - const striked = strike() + const to = setTimeout(() => { + const striked = strike() if (striked) { window.localStorage.setItem('striked', 'yep') }