(folders: FolderEntry[])
| 24 | } |
| 25 | |
| 26 | function buildMoveNoteSuggestions(folders: FolderEntry[]): PromptSuggestion[] { |
| 27 | const byValue = new Map<string, PromptSuggestion>() |
| 28 | const push = (value: string, detail?: string): void => { |
| 29 | if (!byValue.has(value)) byValue.set(value, { value, detail }) |
| 30 | } |
| 31 | |
| 32 | push('inbox', 'Root') |
| 33 | push('archive', 'Root') |
| 34 | |
| 35 | for (const folder of folders) { |
| 36 | if (folder.folder !== 'inbox' && folder.folder !== 'archive') continue |
| 37 | const value = folder.subpath ? `${folder.folder}/${folder.subpath}` : folder.folder |
| 38 | push(value, folder.subpath ? folder.folder : 'Root') |
| 39 | } |
| 40 | |
| 41 | return [...byValue.values()].sort((a, b) => { |
| 42 | const aDepth = a.value.split('/').length |
| 43 | const bDepth = b.value.split('/').length |
| 44 | return aDepth - bDepth || a.value.localeCompare(b.value) |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | export function validateMoveNoteTarget(value: string): string | null { |
| 49 | const normalized = normalizeMoveTarget(value) |
no test coverage detected