(settings: VaultSettings | null | undefined)
| 524 | * value is kept for them. Applied on every vault open. |
| 525 | */ |
| 526 | export 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 | |
| 557 | let viewPersistTimer: ReturnType<typeof setTimeout> | null = null |
| 558 | let pendingViewPatch: VaultViewSettings = {} |
no test coverage detected