fix: clear all add toast if nothing

This commit is contained in:
0xMRTT 2023-08-21 00:31:33 +02:00
parent aafd9d5a2b
commit 838cb0328f

View File

@ -207,6 +207,7 @@ class BavarderWindow(Adw.ApplicationWindow):
self.scroll_down_button.set_visible(True)
def on_clear_all(self, *args):
if self.app.data["chats"]:
dialog = Adw.MessageDialog(
heading=_("Delete All Chats"),
body=_("Are you sure you want to delete all chats in this thread? This can't be undone!"),
@ -223,18 +224,25 @@ class BavarderWindow(Adw.ApplicationWindow):
dialog.set_transient_for(self)
dialog.present()
else:
toast = Adw.Toast()
toast.set_title(_("Nothing to clear!"))
self.toast_overlay.add_toast(toast)
def on_clear_all_response(self, _widget, response):
if response == "delete":
toast = Adw.Toast()
if self.app.data["chats"]:
if self.content:
self.stack.set_visible_child(self.main)
self.main_list.remove_all()
del self.chat["content"]
self.stack.set_visible_child(self.status_no_chat)
toast = Adw.Toast()
toast.set_title(_("All chats cleared!"))
else:
toast.set_title(_("Nothing to clear!"))
self.toast_overlay.add_toast(toast)
def on_export(self, *args):
@ -242,6 +250,10 @@ class BavarderWindow(Adw.ApplicationWindow):
dialog = ExportDialog(self, self.chat["content"])
dialog.set_transient_for(self)
dialog.present()
else:
toast = Adw.Toast()
toast.set_title(_("Nothing to export!"))
self.toast_overlay.add_toast(toast)
# PROVIDER - ONLINE
def load_provider_selector(self):