Skip to content

Commit fd6440f

Browse files
committed
fix(toast): read theme from localStorage (context is out of scope)
- ToastProvider wraps VisualSettingsProvider, so useVisualSettings was always undefined - Circular constraint (Achievement uses Toast, VisualSettings uses Achievement) prevents reordering - Read fezcodex-theme directly from localStorage at mount — toasts are transient
1 parent e0cbc4f commit fd6440f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/components/Toast.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TerminalIcon,
99
} from '@phosphor-icons/react';
1010
import { Link } from 'react-router-dom';
11-
import { useVisualSettings } from '../context/VisualSettingsContext';
11+
import * as LocalStorageManager from '../utils/LocalStorageManager';
1212

1313
const Toast = ({
1414
id,
@@ -20,8 +20,11 @@ const Toast = ({
2020
icon,
2121
links,
2222
}) => {
23-
const visualSettings = useVisualSettings();
24-
const theme = visualSettings?.fezcodexTheme;
23+
// ToastProvider sits above VisualSettingsProvider in the tree (circular
24+
// constraint — AchievementProvider toasts, VisualSettings depends on
25+
// Achievement), so we read the theme straight from localStorage. Toasts are
26+
// short-lived so reading once at mount is fine.
27+
const theme = LocalStorageManager.get('fezcodex-theme', 'brutalist');
2528
const isTerracotta = theme === 'terracotta';
2629
const isLuxe = theme === 'luxe';
2730

0 commit comments

Comments
 (0)