Q184: the page, its sections, filters and selections survive page switches and restarts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2790d88186
commit
72cf57ce3a
27 files changed
+235
-38
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { loadViewState } from "./view-state";
|
||||
import { loadOnboardingDraft } from "./onboarding-progress";
|
||||
import type { DatabaseSync, StatementSync } from "node:sqlite";
|
||||
import type { AppSnapshot } from "../../shared/domain";
|
||||
@@ -88,6 +89,7 @@ export class SnapshotService {
|
||||
activeOrgId,
|
||||
uiPreferences: this.resolveUiPreferences(),
|
||||
onboardingDraft: loadOnboardingDraft(this.db),
|
||||
viewState: loadViewState(this.db),
|
||||
autonomousPaused: this.resolveAutonomousPaused(),
|
||||
integrationKeys: new IntegrationKeyStore(this.db).statuses(),
|
||||
organizations,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
|
||||
export function loadViewState(db: DatabaseSync): Record<string, unknown> {
|
||||
const row = db.prepare("select view_state_json from app_state where id = 1").get() as { view_state_json: string | null } | undefined;
|
||||
return row?.view_state_json ? JSON.parse(row.view_state_json) as Record<string, unknown> : {};
|
||||
}
|
||||
|
||||
/** Remembers one piece of where the operator was; null forgets it. */
|
||||
export function saveViewState(db: DatabaseSync, key: string, value: unknown): void {
|
||||
const path = `$.${JSON.stringify(key)}`;
|
||||
db.prepare(`
|
||||
insert into app_state(id, view_state_json, updated_at) values (1, json_object(), ?)
|
||||
on conflict(id) do nothing
|
||||
`).run(new Date().toISOString());
|
||||
if (value === null) {
|
||||
db.prepare("update app_state set view_state_json = json_remove(coalesce(view_state_json, json_object()), ?) where id = 1").run(path);
|
||||
return;
|
||||
}
|
||||
db.prepare("update app_state set view_state_json = json_set(coalesce(view_state_json, json_object()), ?, json(?)) where id = 1").run(path, JSON.stringify(value));
|
||||
}
|
||||
Reference in new issue
Block a user