feat(RealityOverridePage): persist background visibility state using localStorage
This commit is contained in:
parent
53ed27e250
commit
b2c3580e17
|
|
@ -100,17 +100,19 @@ export default function RealityOverridePage({ onBack }: { onBack: () => void })
|
|||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const msgIdRef = useRef(0);
|
||||
const fadeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
||||
const pausedRef = useRef(false);
|
||||
const pausedRef = useRef(localStorage.getItem('ro-bg') === 'off');
|
||||
const lastTapRef = useRef(0);
|
||||
|
||||
const [wsStatus, setWsStatus] = useState<'connecting' | 'connected' | 'disconnected'>('connecting');
|
||||
const [currentCmd, setCurrentCmd] = useState<Msg | null>(null);
|
||||
const [history, setHistory] = useState<Msg[]>([]);
|
||||
const [bgVisible, setBgVisible] = useState(true);
|
||||
const [bgVisible, setBgVisible] = useState(() => localStorage.getItem('ro-bg') !== 'off');
|
||||
|
||||
const toggleBg = () => {
|
||||
pausedRef.current = !pausedRef.current;
|
||||
setBgVisible(!pausedRef.current);
|
||||
const next = !pausedRef.current;
|
||||
setBgVisible(next);
|
||||
localStorage.setItem('ro-bg', next ? 'on' : 'off');
|
||||
};
|
||||
|
||||
const handleTouchEnd = () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user