Files
tolaria/src/utils/viewIdentity.ts
2026-05-12 19:33:53 +02:00

21 lines
766 B
TypeScript

import type { SidebarSelection, ViewFile } from '../types'
export function viewIdentityKey(view: ViewFile): string {
return `${view.rootPath ?? ''}\n${view.filename}`
}
export function viewSelectionForView(view: ViewFile): SidebarSelection {
return view.rootPath
? { kind: 'view', filename: view.filename, rootPath: view.rootPath }
: { kind: 'view', filename: view.filename }
}
export function viewMatchesSelection(view: ViewFile, selection: SidebarSelection): boolean {
if (selection.kind !== 'view') return false
return view.filename === selection.filename && (view.rootPath ?? '') === (selection.rootPath ?? '')
}
export function viewVaultPath(view: ViewFile, fallbackVaultPath: string): string {
return view.rootPath ?? fallbackVaultPath
}