Files
wehub-resource-sync 2114b14ee0
Sync main into demo / sync (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:26 +08:00

30 lines
747 B
TypeScript

import type { NotesTodo } from '../types';
export function normalizeTodoText(text: string): string {
return text.trim();
}
export function partitionVisibleTodos(
todos: NotesTodo[],
query: string,
editingId: string | null,
): { incomplete: NotesTodo[]; completed: NotesTodo[] } {
const loweredQuery = query.trim().toLowerCase();
const incomplete: NotesTodo[] = [];
const completed: NotesTodo[] = [];
for (const todo of todos) {
const matchesQuery =
todo.id === editingId || !loweredQuery || todo.text.toLowerCase().includes(loweredQuery);
if (!matchesQuery) continue;
if (todo.completed) {
completed.push(todo);
} else {
incomplete.push(todo);
}
}
return { incomplete, completed };
}