( folders: FolderEntry[], settings: VaultSettings | null | undefined, activePath: string | null )
| 1033 | } |
| 1034 | |
| 1035 | function computeStartupCollapsedFolders( |
| 1036 | folders: FolderEntry[], |
| 1037 | settings: VaultSettings | null | undefined, |
| 1038 | activePath: string | null |
| 1039 | ): string[] { |
| 1040 | const normalizedSettings = normalizeVaultSettings(settings) |
| 1041 | const primaryNotesAtRoot = isPrimaryNotesAtRoot(normalizedSettings) |
| 1042 | const orderedKeys: string[] = [] |
| 1043 | const seen = new Set<string>() |
| 1044 | const pushKey = (key: string): void => { |
| 1045 | if (seen.has(key)) return |
| 1046 | seen.add(key) |
| 1047 | orderedKeys.push(key) |
| 1048 | } |
| 1049 | |
| 1050 | pushKey('quick:') |
| 1051 | if (!primaryNotesAtRoot) pushKey('inbox:') |
| 1052 | for (const folder of folders) { |
| 1053 | if (!folder.subpath) continue |
| 1054 | pushKey(`${folder.folder}:${folder.subpath}`) |
| 1055 | } |
| 1056 | |
| 1057 | if (!activePath || activePath.startsWith('zen://')) return orderedKeys |
| 1058 | |
| 1059 | const folder = folderForVaultRelativePath(activePath, normalizedSettings) |
| 1060 | if (!folder) return orderedKeys |
| 1061 | |
| 1062 | const expandedKeys = new Set<string>() |
| 1063 | if (folder === 'quick') { |
| 1064 | expandedKeys.add('quick:') |
| 1065 | } else if (folder === 'inbox' && !primaryNotesAtRoot) { |
| 1066 | expandedKeys.add('inbox:') |
| 1067 | } |
| 1068 | |
| 1069 | const parentSubpath = noteFolderSubpath({ folder, path: activePath }, normalizedSettings) |
| 1070 | if (parentSubpath) { |
| 1071 | let acc = '' |
| 1072 | for (const segment of parentSubpath.split('/').filter(Boolean)) { |
| 1073 | acc = acc ? `${acc}/${segment}` : segment |
| 1074 | expandedKeys.add(`${folder}:${acc}`) |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | return orderedKeys.filter((key) => !expandedKeys.has(key)) |
| 1079 | } |
| 1080 | |
| 1081 | export interface NoteJumpLocation { |
| 1082 | path: string |
no test coverage detected