MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / applyPortableConfig

Function applyPortableConfig

packages/app-core/src/store.ts:7392–7408  ·  view source on GitHub ↗

Apply an externally-changed portable config (synced dotfile / hand-edit) * to the live store and the localStorage cache. Uses setState directly so it * doesn't re-trigger a write back out to the file.

(next: AppConfigPortable)

Source from the content-addressed store, hash-verified

7390 * to the live store and the localStorage cache. Uses setState directly so it
7391 * doesn't re-trigger a write back out to the file. */
7392function applyPortableConfig(next: AppConfigPortable): void {
7393 if (!next || typeof next !== 'object') return
7394 const current = collectPrefs(useStore.getState())
7395 const merged = normalizePrefs({ ...current, ...(next as Partial<Prefs>) })
7396 cachedInitialPrefs = merged
7397 try {
7398 localStorage.setItem(PREFS_KEY, JSON.stringify(merged))
7399 } catch {
7400 /* ignore */
7401 }
7402 const patch: Record<string, unknown> = {}
7403 const mergedRecord = merged as unknown as Record<string, unknown>
7404 for (const key of PORTABLE_PREF_KEYS) {
7405 patch[key] = mergedRecord[key]
7406 }
7407 useStore.setState(patch as Partial<Store>)
7408}
7409
7410let configSyncInitialized = false
7411

Callers 1

initConfigSyncFunction · 0.85

Calls 2

collectPrefsFunction · 0.85
normalizePrefsFunction · 0.85

Tested by

no test coverage detected