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

Function viewPrefsFromVault

packages/app-core/src/store.ts:526–555  ·  view source on GitHub ↗
(settings: VaultSettings | null | undefined)

Source from the content-addressed store, hash-verified

524 * value is kept for them. Applied on every vault open.
525 */
526export function viewPrefsFromVault(settings: VaultSettings | null | undefined): Partial<Store> {
527 const v = settings?.view
528 if (!v || typeof v !== 'object') return {}
529 const patch: Partial<Store> = {}
530 if (typeof v.noteSortOrder === 'string' && VALID_SORTS.includes(v.noteSortOrder as NoteSortOrder)) {
531 patch.noteSortOrder = v.noteSortOrder as NoteSortOrder
532 }
533 if (typeof v.groupByKind === 'boolean') patch.groupByKind = v.groupByKind
534 if (
535 typeof v.tasksViewMode === 'string' &&
536 VALID_TASKS_VIEW_MODES.includes(v.tasksViewMode as TasksViewMode)
537 ) {
538 patch.tasksViewMode = v.tasksViewMode as TasksViewMode
539 }
540 if (
541 typeof v.kanbanGroupBy === 'string' &&
542 VALID_KANBAN_GROUP_BYS.includes(v.kanbanGroupBy as KanbanGroupBy)
543 ) {
544 patch.kanbanGroupBy = v.kanbanGroupBy as KanbanGroupBy
545 }
546 if (v.kanbanColumnTitles && typeof v.kanbanColumnTitles === 'object') {
547 patch.kanbanColumnTitles = normalizeKanbanColumnTitles(v.kanbanColumnTitles)
548 }
549 if (typeof v.autoReveal === 'boolean') patch.autoReveal = v.autoReveal
550 if (v.systemFolderLabels && typeof v.systemFolderLabels === 'object') {
551 patch.systemFolderLabels = normalizeSystemFolderLabels(v.systemFolderLabels)
552 }
553 if (typeof v.unifiedSidebar === 'boolean') patch.unifiedSidebar = v.unifiedSidebar
554 return patch
555}
556
557let viewPersistTimer: ReturnType<typeof setTimeout> | null = null
558let pendingViewPatch: VaultViewSettings = {}

Callers 3

restoreWorkspaceForVaultFunction · 0.85
store.tsFile · 0.85
store.test.tsFile · 0.85

Calls 2

Tested by

no test coverage detected