aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/notes/NotesPage.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-16 20:59:09 +0200
committerDanilo M. <danix@danix.xyz>2026-10-16 20:59:09 +0200
commitd423ec2646d444523fd44c92864988445cf072d2 (patch)
tree50fc70c9d6bacbaa94fb2821e5c67b0808cdad74 /desktop/modules/notes/NotesPage.qml
parent23a7b36d0d20ef1f809db0b5d69f1416021afb91 (diff)
downloadquickshell-d423ec2646d444523fd44c92864988445cf072d2.tar.gz
quickshell-d423ec2646d444523fd44c92864988445cf072d2.zip
notes: delete asks before it destroys
The confirm was on the second click, after the first had already removed the file and the entry, so the 'Confirm?' label promised a check that had already happened and one stray click lost the note. The first click now only arms the button; the second removes and pushes the removal.
Diffstat (limited to 'desktop/modules/notes/NotesPage.qml')
-rw-r--r--desktop/modules/notes/NotesPage.qml36
1 files changed, 22 insertions, 14 deletions
diff --git a/desktop/modules/notes/NotesPage.qml b/desktop/modules/notes/NotesPage.qml
index 88382fc..585fcfb 100644
--- a/desktop/modules/notes/NotesPage.qml
+++ b/desktop/modules/notes/NotesPage.qml
@@ -37,10 +37,13 @@ Item {
property string bodyError: ""
// A write or git command is in flight; the buttons stand down meanwhile.
property bool busy: false
- // "create" | "edit" | "delete" once that write has landed and the commit
- // and push are still owed. It outlives any timer, so a click after a pause
- // pushes the note that was already written instead of writing it again.
+ // "create" | "edit" once that write has landed and the commit and push are
+ // still owed. It outlives any timer, so a click after a pause pushes the
+ // note that was already written instead of writing it again.
property string awaiting: ""
+ // Delete is confirmed before anything is destroyed: the first click only
+ // arms the button, the second removes and pushes.
+ property bool confirmDelete: false
// The shared Switch writes `checked` itself, which drops the binding
// above; StatusRow.qml documents the same and resyncs the same way.
@@ -50,6 +53,7 @@ Item {
page.bodyError = "";
page.preview = note !== null;
page.awaiting = "";
+ page.confirmDelete = false;
titleField.text = note ? note.title : "";
// Clear before the assignment below: that assignment is what retargets
// the body FileView, and its load may land synchronously, so clearing
@@ -62,6 +66,7 @@ Item {
function toList() {
page.awaiting = "";
+ page.confirmDelete = false;
page.busy = false;
page.editing = null;
page.bodyError = "";
@@ -98,22 +103,24 @@ Item {
function remove() {
if (page.busy || page.editing === null) return;
const id = page.editing.id;
- if (page.awaiting === "delete") {
- page.busy = true;
- page.owner.commitPush("delete", id, (ok, msg) => {
- page.busy = false;
- if (!ok) { page.owner.lastError = msg; return; }
- page.toList();
- });
- return;
- }
+ // Nothing is destroyed until the second click: a note lost to one
+ // stray click is only recoverable out of git history by hand.
+ if (!page.confirmDelete) { page.confirmDelete = true; return; }
+ page.confirmDelete = false;
page.owner.lastError = "";
page.busy = true;
page.owner.remove(id, (ok, msg) => {
page.busy = false;
if (!ok) { page.owner.lastError = msg; return; }
if (!page.owner.gitEnabled) { page.toList(); return; }
- page.awaiting = "delete";
+ // The removal is confirmed, so the push follows it rather than
+ // asking for a third click.
+ page.busy = true;
+ page.owner.commitPush("delete", id, (ok2, msg2) => {
+ page.busy = false;
+ if (!ok2) page.owner.lastError = msg2;
+ page.toList();
+ });
});
}
@@ -290,7 +297,8 @@ Item {
visible: page.editing !== null
danger: true
enabled: !page.busy
- text: page.awaiting === "delete" ? "Confirm?" : "Delete"
+ text: page.busy ? "Deleting…"
+ : page.confirmDelete ? "Confirm?" : "Delete"
onClicked: page.remove()
}