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

Function initConfigSync

packages/app-core/src/store.ts:7418–7444  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7416 * external edits for live reload.
7417 */
7418export function initConfigSync(): void {
7419 if (configSyncInitialized) return
7420 const bridge = typeof window !== 'undefined' ? window.zen : undefined
7421 if (!bridge || typeof bridge.getConfigSync !== 'function') return
7422 if (!configFileEnabled) return
7423 configSyncInitialized = true
7424
7425 // Migration for existing users: no config file yet → create one from their
7426 // current preferences so the dotfile starts as an exact mirror of today's
7427 // setup, no reconfiguration needed.
7428 if (!configFileHadContent && typeof bridge.setConfig === 'function') {
7429 try {
7430 const prefs = collectPrefs(useStore.getState())
7431 void bridge.setConfig(pickPortablePrefs(prefs as unknown as Record<string, unknown>))
7432 } catch {
7433 /* ignore */
7434 }
7435 }
7436
7437 if (typeof bridge.onConfigChange === 'function') {
7438 try {
7439 bridge.onConfigChange((nextCfg) => applyPortableConfig(nextCfg))
7440 } catch {
7441 /* ignore */
7442 }
7443 }
7444}
7445
7446function applyCustomThemes(themes: CustomTheme[]): void {
7447 useStore.setState({ customThemes: themes })

Callers 1

AppFunction · 0.90

Calls 5

pickPortablePrefsFunction · 0.90
collectPrefsFunction · 0.85
applyPortableConfigFunction · 0.85
setConfigMethod · 0.80
onConfigChangeMethod · 0.80

Tested by

no test coverage detected