Book style tweak editor: fix double notification on discard

Avoid two identical stacked notifications "Book tweak not modified"
after Close + Discard when text was modified.
This commit is contained in:
poire-z
2024-08-25 20:40:08 +02:00
parent db8786f058
commit 9f308399f9
2 changed files with 9 additions and 9 deletions

View File

@@ -159,6 +159,7 @@ local InputDialog = FocusManager:extend{
-- - on success: as the notification text instead of the default one
-- - on failure: in an InfoMessage
close_callback = nil, -- Called when closing (if discarded or saved, after save_callback if saved)
-- (passed true/false if text modified and saved/discarded, nil if closed with text unmodified)
edited_callback = nil, -- Called on each text modification
-- For use by TextEditor plugin:
@@ -844,7 +845,7 @@ function InputDialog:_addSaveCloseButtons()
cancel_text = self.close_cancel_button_text or _("Cancel"),
choice1_text = self.close_discard_button_text or _("Discard"),
choice1_callback = function()
if self.close_callback then self.close_callback() end
if self.close_callback then self.close_callback(false) end
UIManager:close(self)
UIManager:show(Notification:new{
text = self.close_discarded_notif_text or _("Changes discarded"),
@@ -863,7 +864,7 @@ function InputDialog:_addSaveCloseButtons()
})
end
else -- nil or true
if self.close_callback then self.close_callback() end
if self.close_callback then self.close_callback(true) end
UIManager:close(self)
UIManager:show(Notification:new{
text = msg or _("Saved"),