diff options
Diffstat (limited to 'src/features/surface-host/logic/todo.ts')
| -rw-r--r-- | src/features/surface-host/logic/todo.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/features/surface-host/logic/todo.ts b/src/features/surface-host/logic/todo.ts index e442e78..8b8a5ef 100644 --- a/src/features/surface-host/logic/todo.ts +++ b/src/features/surface-host/logic/todo.ts @@ -16,33 +16,33 @@ export type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled"; export interface TodoItem { - readonly content: string; - readonly status: TodoStatus; + readonly content: string; + readonly status: TodoStatus; } export interface TodoData { - readonly todos: readonly TodoItem[]; + readonly todos: readonly TodoItem[]; } const STATUSES = new Set<string>(["pending", "in_progress", "completed", "cancelled"]); function isTodoItem(v: unknown): v is TodoItem { - if (typeof v !== "object" || v === null) return false; - const o = v as Record<string, unknown>; - return typeof o.content === "string" && typeof o.status === "string" && STATUSES.has(o.status); + if (typeof v !== "object" || v === null) return false; + const o = v as Record<string, unknown>; + return typeof o.content === "string" && typeof o.status === "string" && STATUSES.has(o.status); } export function parseTodoPayload(payload: unknown): TodoData | null { - if (typeof payload !== "object" || payload === null) return null; - const obj = payload as Record<string, unknown>; - const raw = obj.todos; - if (!Array.isArray(raw)) return null; - const todos: TodoItem[] = []; - for (const entry of raw) { - if (!isTodoItem(entry)) return null; - todos.push(entry); - } - return { todos }; + if (typeof payload !== "object" || payload === null) return null; + const obj = payload as Record<string, unknown>; + const raw = obj.todos; + if (!Array.isArray(raw)) return null; + const todos: TodoItem[] = []; + for (const entry of raw) { + if (!isTodoItem(entry)) return null; + todos.push(entry); + } + return { todos }; } /** The `rendererId` the `todo` extension's `custom` surface field uses. */ |
