Skip to content

Commit c82bc11

Browse files
committed
Dashboard persist across refresh
1 parent 46e3ffc commit c82bc11

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

pecan/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ function App() {
7878
dataStore.clearPersistedSnapshot();
7979
dataStore.notifyBoundsRefresh();
8080
clearCheckpoints();
81+
localStorage.removeItem("dash:plots");
82+
window.location.reload();
8183
};
8284

8385
useEffect(() => {

pecan/src/pages/Dashboard.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ function Dashboard() {
103103

104104
// Plotting State
105105
// =====================================================================
106-
const [plots, setPlots] = useState<Plot[]>([]);
106+
const [plots, setPlots] = useState<Plot[]>(() => {
107+
try {
108+
const raw = localStorage.getItem("dash:plots");
109+
if (raw) return JSON.parse(raw) as Plot[];
110+
} catch { /* ignore */ }
111+
return [];
112+
});
107113
const [nextPlotId, setNextPlotId] = useState(1);
108114
const livePlotsSnapshotRef = useRef<Plot[] | null>(null);
109115
// Stores the loadedAtMs of the replay session whose layout has been applied,
@@ -162,6 +168,13 @@ function Dashboard() {
162168
}
163169
}, [plots, viewMode, sortingMethod, session, saveConfig]);
164170

171+
// Persist plots locally so they survive page refresh
172+
useEffect(() => {
173+
try {
174+
localStorage.setItem("dash:plots", JSON.stringify(plots));
175+
} catch { /* ignore */ }
176+
}, [plots]);
177+
165178
// Data
166179
// =====================================================================
167180

0 commit comments

Comments
 (0)