handleTodoListRequest handles todo list requests
(wsConn *WebSocketConnection, payload map[string]any)
| 527 | |
| 528 | // handleTodoListRequest handles todo list requests |
| 529 | func (h *WebSocketHandler) handleTodoListRequest(wsConn *WebSocketConnection, payload map[string]any) { |
| 530 | listName := "default" |
| 531 | if name, ok := payload["list_name"].(string); ok && name != "" { |
| 532 | listName = name |
| 533 | } |
| 534 | |
| 535 | todoList, err := h.todoManager.LoadTodoList(listName) |
| 536 | if err != nil { |
| 537 | // 如果不存在,返回空列表 |
| 538 | todoList = &builtin.TodoList{ |
| 539 | ID: fmt.Sprintf("list_%s_%d", listName, time.Now().UnixNano()), |
| 540 | Name: listName, |
| 541 | Todos: []builtin.TodoItem{}, |
| 542 | CreatedAt: time.Now(), |
| 543 | UpdatedAt: time.Now(), |
| 544 | Metadata: make(map[string]any), |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | h.sendMessage(wsConn, "todo_list_response", map[string]any{ |
| 549 | "todos": todoList.Todos, |
| 550 | }) |
| 551 | } |
| 552 | |
| 553 | // handleTodoCreate handles todo creation |
| 554 | func (h *WebSocketHandler) handleTodoCreate(wsConn *WebSocketConnection, payload map[string]any) { |
no test coverage detected