Skip to content

Commit df8f72d

Browse files
committed
Persist last opened simulation when loading from library
1 parent 38406d9 commit df8f72d

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

functions/_lib/buildInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const APP_VERSION = "0.8.0";
2-
export const APP_COMMIT = "8ac6d46d";
2+
export const APP_COMMIT = "38406d9a";
33
export const APP_BUILD_LABEL = `v${APP_VERSION}+${APP_COMMIT}`;

src/components/Sidebar.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ export function Sidebar() {
420420
return fallback;
421421
}
422422
});
423+
const persistSelectedSimulationRef = (ref: string) => {
424+
setSelectedSimulationRef(ref);
425+
try {
426+
localStorage.setItem(LAST_SIMULATION_REF_KEY, ref);
427+
} catch {
428+
// ignore
429+
}
430+
};
423431
const [startupSimulationApplied, setStartupSimulationApplied] = useState(false);
424432
const [storageImportMode, setStorageImportMode] = useState<"merge" | "replace">("merge");
425433
const [storageStatus, setStorageStatus] = useState("");
@@ -554,12 +562,7 @@ export function Sidebar() {
554562
const exists = simulationPresets.some((preset) => preset.id === presetId);
555563
if (!exists) {
556564
const fallback = `builtin:${selectedScenarioId}`;
557-
setSelectedSimulationRef(fallback);
558-
try {
559-
localStorage.setItem(LAST_SIMULATION_REF_KEY, fallback);
560-
} catch {
561-
// ignore
562-
}
565+
persistSelectedSimulationRef(fallback);
563566
}
564567
}
565568
}, [selectedSimulationRef, simulationPresets, selectedScenarioId]);
@@ -935,12 +938,7 @@ export function Sidebar() {
935938
const savedId = saveCurrentSimulationPreset(trimmed);
936939
if (savedId) {
937940
const ref = `saved:${savedId}`;
938-
setSelectedSimulationRef(ref);
939-
try {
940-
localStorage.setItem(LAST_SIMULATION_REF_KEY, ref);
941-
} catch {
942-
// ignore
943-
}
941+
persistSelectedSimulationRef(ref);
944942
setSimulationSaveStatus(`Saved simulation: ${trimmed}`);
945943
}
946944
setNewPresetName("");
@@ -2338,7 +2336,7 @@ export function Sidebar() {
23382336
className="inline-action"
23392337
onClick={() => {
23402338
loadSimulationPreset(preset.id);
2341-
setSelectedSimulationRef(`saved:${preset.id}`);
2339+
persistSelectedSimulationRef(`saved:${preset.id}`);
23422340
}}
23432341
type="button"
23442342
>

src/lib/buildInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const APP_VERSION = "0.8.0";
2-
export const APP_COMMIT = "8ac6d46d";
2+
export const APP_COMMIT = "38406d9a";
33
export const APP_BUILD_LABEL = `v${APP_VERSION}+${APP_COMMIT}`;

0 commit comments

Comments
 (0)