diff --git a/src/controller/buffers/mastodon/notifications.py b/src/controller/buffers/mastodon/notifications.py index ba84f244..68951382 100644 --- a/src/controller/buffers/mastodon/notifications.py +++ b/src/controller/buffers/mastodon/notifications.py @@ -2,9 +2,11 @@ import time import logging import widgetUtils +import output from controller.buffers.mastodon.base import BaseBuffer from sessions.mastodon import compose, templates from wxUI import buffers +from wxUI.dialogs.mastodon import dialogs as mastodon_dialogs log = logging.getLogger("controller.buffers.mastodon.notifications") @@ -46,6 +48,9 @@ class NotificationsBuffer(BaseBuffer): def destroy_status(self, *args, **kwargs): index = self.buffer.list.get_selected() item = self.session.db[self.name][index] + answer = mastodon_dialogs.delete_notification_dialog() + if answer == False: + return items = self.session.db[self.name] try: self.session.api.notifications_dismiss(id=item.id) @@ -54,4 +59,5 @@ class NotificationsBuffer(BaseBuffer): output.speak(_("Notification dismissed.")) except Exception as e: self.session.sound.play("error.ogg") + log.exception("") self.session.db[self.name] = items diff --git a/src/wxUI/dialogs/mastodon/dialogs.py b/src/wxUI/dialogs/mastodon/dialogs.py index cb485618..a42f6ffb 100644 --- a/src/wxUI/dialogs/mastodon/dialogs.py +++ b/src/wxUI/dialogs/mastodon/dialogs.py @@ -18,6 +18,14 @@ def delete_post_dialog(): dlg.Destroy() return result +def delete_notification_dialog(): + result = False + dlg = wx.MessageDialog(None, _("Are you sure you want to dismiss this notification? If you dismiss a mention notification, it also disappears from your mentions buffer. The post is not going to be deleted from the instance, though."), _("Dismiss"), wx.ICON_QUESTION|wx.YES_NO) + if dlg.ShowModal() == wx.ID_YES: + result = True + dlg.Destroy() + return result + def clear_list(): result = False dlg = wx.MessageDialog(None, _("Do you really want to empty this buffer? It's items will be removed from the list but not from the instance"), _(u"Empty buffer"), wx.ICON_QUESTION|wx.YES_NO)