fix(sheet): make "Mark done" mark it done
The button advanced one step round the untouched → doing → done cycle, so pressing "Mark done" on a fresh event produced "doing it" and needed a second press. Worse, the press after "done" cleared the status outright rather than undoing anything. Three states need three targets — that is the control directly above it. This one is the commit, so it sets done and back. cycleStatus had no other caller and is gone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
edc6f3e4bb
commit
2a7a117705
@@ -91,28 +91,11 @@ export function useProgress() {
|
||||
[patch],
|
||||
);
|
||||
|
||||
const cycleStatus = useCallback(
|
||||
(id: string) => {
|
||||
setProgress((prev) => {
|
||||
// Untouched → doing → done → untouched. One control, three states, in
|
||||
// the order the reader actually moves through them.
|
||||
const current = prev[id]?.status;
|
||||
const next: Status | undefined =
|
||||
current === undefined ? "doing" : current === "doing" ? "done" : undefined;
|
||||
const merged: Progress = {
|
||||
...prev[id],
|
||||
status: next,
|
||||
at: new Date().toISOString(),
|
||||
};
|
||||
if (isEmpty(merged)) {
|
||||
const { [id]: _removed, ...rest } = prev;
|
||||
return rest;
|
||||
}
|
||||
return { ...prev, [id]: merged };
|
||||
});
|
||||
},
|
||||
[],
|
||||
);
|
||||
// There was a `cycleStatus` here that advanced untouched → doing → done →
|
||||
// untouched from a single control. It is gone: the only caller was the sheet's
|
||||
// "Mark done" button, where one press on a fresh event produced "doing it" and
|
||||
// the press after "done" cleared the status instead of undoing it. Status is
|
||||
// set outright now, by a control per state.
|
||||
|
||||
const setDaily = useCallback(
|
||||
(id: string, daily: boolean | undefined) => patch(id, { daily }),
|
||||
@@ -146,7 +129,6 @@ export function useProgress() {
|
||||
progress,
|
||||
patch,
|
||||
setStatus,
|
||||
cycleStatus,
|
||||
setDaily,
|
||||
setEffort,
|
||||
setNote,
|
||||
|
||||
Reference in New Issue
Block a user