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

Function buildMoveNoteSuggestions

packages/app-core/src/lib/move-note.ts:26–46  ·  view source on GitHub ↗
(folders: FolderEntry[])

Source from the content-addressed store, hash-verified

24}
25
26function 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
48export function validateMoveNoteTarget(value: string): string | null {
49 const normalized = normalizeMoveTarget(value)

Callers 1

buildMoveNotePromptFunction · 0.85

Calls 1

pushFunction · 0.70

Tested by

no test coverage detected