mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-27 12:26:33 -08:00
Properly remember flightlist closed state across pages
This commit is contained in:
1 parent
183f986eee
commit
64d1aa6209
2 files changed
+33
-23
No files matched your search
@@ -232,33 +232,12 @@ function PreviewSection({ open }: { open: boolean }) {
|
||||
}
|
||||
|
||||
export function Sidebar() {
|
||||
const { completion } = useTrackingChecklist();
|
||||
const [closed, setClosed] = useState(true);
|
||||
const [closing, setClosing] = useState(false);
|
||||
const { closed, closing, toggleClosed } = useTrackingChecklist();
|
||||
|
||||
const closedHight = '90px';
|
||||
const checklistSize = closed ? closedHight : 'calc(100% - 16px)';
|
||||
const previewSize = closed ? `calc(100% - ${closedHight} - 24px)` : '0%';
|
||||
|
||||
const toggleClosed = () => setClosed((closed) => !closed);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setClosing(true);
|
||||
const ref = setTimeout(() => setClosing(false), 1000);
|
||||
return () => {
|
||||
clearTimeout(ref);
|
||||
setClosing(false);
|
||||
};
|
||||
}, [closed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (completion === 'complete') {
|
||||
setClosed(true);
|
||||
} else if (completion === 'incomplete') {
|
||||
setClosed(false);
|
||||
}
|
||||
}, [completion]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
|
||||
@@ -8,7 +8,14 @@ import {
|
||||
RpcMessage,
|
||||
} from 'solarxr-protocol';
|
||||
import { useWebsocketAPI } from './websocket-api';
|
||||
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import * as Sentry from '@sentry/react';
|
||||
|
||||
export const trackingchecklistIdtoLabel: Record<TrackingChecklistStepId, string> = {
|
||||
@@ -172,6 +179,27 @@ export function provideTrackingChecklist() {
|
||||
[steps]
|
||||
);
|
||||
|
||||
const [closed, setClosed] = useState(true);
|
||||
const [closing, setClosing] = useState(false);
|
||||
const toggleClosed = () => setClosed((closed) => !closed);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setClosing(true);
|
||||
const ref = setTimeout(() => setClosing(false), 1000);
|
||||
return () => {
|
||||
clearTimeout(ref);
|
||||
setClosing(false);
|
||||
};
|
||||
}, [closed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (completion === 'complete') {
|
||||
setClosed(true);
|
||||
} else if (completion === 'incomplete') {
|
||||
setClosed(false);
|
||||
}
|
||||
}, [completion]);
|
||||
|
||||
const ignoreStep = (
|
||||
step: TrackingChecklistStepId,
|
||||
ignore: boolean,
|
||||
@@ -211,6 +239,9 @@ export function provideTrackingChecklist() {
|
||||
progress,
|
||||
completion,
|
||||
warnings,
|
||||
closed,
|
||||
closing,
|
||||
toggleClosed,
|
||||
ignoreStep,
|
||||
toggleSession: (step: TrackingChecklistStepId) =>
|
||||
ignoreStep(step, !sessionIgnoredSteps.includes(step)),
|
||||
|
||||
Reference in new issue
Block a user