| 125 | } |
| 126 | |
| 127 | function priorityColumns(tasks: VaultTask[]): Column[] { |
| 128 | const high: VaultTask[] = [] |
| 129 | const med: VaultTask[] = [] |
| 130 | const low: VaultTask[] = [] |
| 131 | const none: VaultTask[] = [] |
| 132 | for (const task of tasks) { |
| 133 | if (task.checked) continue |
| 134 | if (task.priority === 'high') high.push(task) |
| 135 | else if (task.priority === 'med') med.push(task) |
| 136 | else if (task.priority === 'low') low.push(task) |
| 137 | else none.push(task) |
| 138 | } |
| 139 | // Within each column, surface overdue/today first, then by due date. |
| 140 | const sortByDue = (a: VaultTask, b: VaultTask): number => { |
| 141 | const ad = a.due ?? '9999-12-31' |
| 142 | const bd = b.due ?? '9999-12-31' |
| 143 | if (ad !== bd) return ad < bd ? -1 : 1 |
| 144 | if (a.sourcePath !== b.sourcePath) return a.sourcePath < b.sourcePath ? -1 : 1 |
| 145 | return a.taskIndex - b.taskIndex |
| 146 | } |
| 147 | high.sort(sortByDue) |
| 148 | med.sort(sortByDue) |
| 149 | low.sort(sortByDue) |
| 150 | none.sort(sortByDue) |
| 151 | return [ |
| 152 | { id: 'high', label: 'High', tasks: high }, |
| 153 | { id: 'med', label: 'Medium', tasks: med }, |
| 154 | { id: 'low', label: 'Low', tasks: low }, |
| 155 | { id: 'none', label: 'No priority', tasks: none } |
| 156 | ] |
| 157 | } |
| 158 | |
| 159 | const FOLDER_ORDER: NoteFolder[] = ['inbox', 'quick', 'archive'] |
| 160 | const FOLDER_LABEL: Record<NoteFolder, string> = { |