feat(favicon): swap tab favicon for SFW vs NSFW boards

This commit is contained in:
plebeius
2026-03-02 21:08:46 +08:00
parent ea0789faa1
commit 3bd1c0ad4f
4 changed files with 71 additions and 1 deletions
+16
View File
@@ -7,6 +7,7 @@ import { useResolvedSubplebbitAddress } from './use-resolved-subplebbit-address'
import { useAccountComment } from '@bitsocialhq/pkc-react-hooks';
import useSpecialThemeStore from '../stores/use-special-theme-store';
import { isChristmas } from '../lib/utils/time-utils';
import { updateFavicon, isSfwBoard } from '../lib/update-favicon';
const themeClasses = ['yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'tomorrow', 'photon'];
@@ -80,11 +81,26 @@ const useTheme = (): [string, (theme: string) => void] => {
return storedTheme || 'yotsuba';
}, [location.pathname, isEnabled, isInAllView, isInSubscriptionsView, isInModView, subplebbitAddress, directories, themes]);
const sfw = isSfwBoard({
pathname: location.pathname,
isSpecialTheme: !!isEnabled,
isInAllView,
isInSubscriptionsView,
isInModView,
subplebbitAddress,
directories,
});
// Update DOM class when theme changes
useEffect(() => {
updateThemeClass(currentTheme);
}, [currentTheme]);
// Update favicon when SFW status changes (separate effect for independent lifecycle)
useEffect(() => {
updateFavicon(sfw);
}, [sfw]);
const setSubplebbitTheme = useCallback(
async (newTheme: string) => {
if (isInAllView || isInSubscriptionsView || isInModView) {