From: Scott Worley Date: Thu, 27 Jan 2022 03:32:16 +0000 (-0800) Subject: Don't change state if it's already in that state X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/da9a271623620d92a82608592d65fc2e4ca08491?ds=sidebyside Don't change state if it's already in that state --- diff --git a/vopamoi.ts b/vopamoi.ts index a98a29b..e997d1c 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -213,12 +213,14 @@ const BrowserUI = { task instanceof HTMLElement && task.focus(); }, - setState: function (state: string) { + setState: function (newState: string) { const task = document.activeElement; if (!task) return; + const oldState = Model.getState(task); + if (newState === oldState) return; const createTimestamp = task.getAttribute("data-created")!; this.moveCursor(1) || this.moveCursor(-1); - return UI.setState(createTimestamp, state, Model.getState(task)); + return UI.setState(createTimestamp, newState, oldState); }, undo: function () { @@ -240,6 +242,7 @@ function handleKey(event: any) { if (event.key == "w") return BrowserUI.setState("waiting"); if (event.key == "d") return BrowserUI.setState("done"); if (event.key == "c") return BrowserUI.setState("cancelled"); + if (event.key == "t") return BrowserUI.setState("todo"); if (event.key == "X") return BrowserUI.setState("deleted"); if (event.key == "u") return BrowserUI.undo(); }