feat: OneThing 桌面待办事项应用 - #1
Merged
Merged
Conversation
- 视图/侧边栏/表单等全部 UI 文本改为中文,dayjs locale 设为 zh-cn - toggleTodo 改为 await 前读取最新值,避免并发切换时 state 覆盖 - loadTodos 新增守卫:等待 pendingToggles 完成后再读 DB,防止旧数据覆盖乐观更新
There was a problem hiding this comment.
Pull request overview
This PR refines the todo app’s state/date handling to eliminate race conditions around toggling completion and to align calendar views’ week boundaries with the app’s Day.js locale configuration (zh-cn).
Changes:
- Add a
pendingTogglesguard soloadTodoswaits for in-flighttoggleTodoupdates before re-fetching. - Update
toggleTodoto compute the newcompletedvalue from the latest store state right before the async DB update. - Remove manual
+1 dayoffsets from week starts/ends in Week/Month/Year views so week calculations rely on Day.js locale week start.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/stores/todo-store.ts | Adds pending-toggle coordination between toggleTodo and loadTodos to reduce race conditions. |
| src/components/views/YearView.tsx | Aligns yearly heatmap week grid start with locale week boundaries. |
| src/components/views/WeekView.tsx | Aligns weekly view start date with locale week boundaries. |
| src/components/views/MonthView.tsx | Aligns monthly calendar range start/end with locale week boundaries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+29
to
+37
| if (pendingToggles.size > 0) { | ||
| await new Promise<void>((resolve) => { | ||
| const check = () => { | ||
| if (pendingToggles.size === 0) resolve(); | ||
| else setTimeout(check, 10); | ||
| }; | ||
| check(); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
OneThing — 基于 Tauri 2 的桌面待办事项应用,界面全中文,设计风格对标 Linear + Things 3。
技术栈
功能
审查要点
src/stores/todo-store.ts— 竞态条件修复,await 前读取最新值src/lib/database.ts— reorderTodos 事务包裹,getDb 并发保护src/components/shared/TodoForm.tsx— useEffect 重置表单状态src/components/shared/TodoItem.tsx— useShallow selector 优化