From 6b735c8cf64b6373e9e419d8c40032998b347617 Mon Sep 17 00:00:00 2001 From: Jamie Gravendeel Date: Mon, 8 Dec 2025 19:00:51 +0100 Subject: [PATCH] window: Undo the correct toast --- cartridges/ui/window.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cartridges/ui/window.py b/cartridges/ui/window.py index a9fd8a7..d82f8a0 100644 --- a/cartridges/ui/window.py +++ b/cartridges/ui/window.py @@ -81,9 +81,9 @@ class Window(Adw.ApplicationWindow): """ toast = Adw.Toast.new(title) if undo: - toast.props.action_name = "win.undo" toast.props.button_label = _("Undo") toast.props.priority = Adw.ToastPriority.HIGH + toast.connect("button-clicked", lambda toast: self._undo(toast)) self._history[toast] = undo self.toast_overlay.add_toast(toast) @@ -132,7 +132,11 @@ class Window(Adw.ApplicationWindow): self.details.edit() - def _undo(self): + def _undo(self, toast: Adw.Toast | None = None): + if toast: + self._history.pop(toast)() + return + try: toast, undo = self._history.popitem() except KeyError: