MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / parseLegacyPersistedState

Function parseLegacyPersistedState

src/store/migration.ts:74–88  ·  view source on GitHub ↗
(legacyData: string)

Source from the content-addressed store, hash-verified

72}
73
74export function parseLegacyPersistedState(legacyData: string): Record<string, unknown> | null {
75 try {
76 const parsed: unknown = JSON.parse(legacyData);
77 if (!isRecord(parsed)) return null;
78
79 // Zustand persist wraps state in { state: {...}, version: number }.
80 if ('state' in parsed) {
81 return isRecord(parsed.state) ? parsed.state : null;
82 }
83
84 return parsed;
85 } catch {
86 return null;
87 }
88}
89
90/**
91 * Apply legacy boolean-to-enum migrations from the old format

Callers 2

migration.test.tsFile · 0.90
migrateFromLegacyStoreFunction · 0.85

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected