Mastodon: Show dialog before dismissing a notification. Mention notifications will make the mention to not be loaded in mentions buffer, as TWBlue reads mentions from the notifications data

This commit is contained in:
Manuel Cortez 2022-12-19 16:50:43 -06:00
parent b8647c29ea
commit b0fa59cc01
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 14 additions and 0 deletions

View File

@ -2,9 +2,11 @@
import time import time
import logging import logging
import widgetUtils import widgetUtils
import output
from controller.buffers.mastodon.base import BaseBuffer from controller.buffers.mastodon.base import BaseBuffer
from sessions.mastodon import compose, templates from sessions.mastodon import compose, templates
from wxUI import buffers from wxUI import buffers
from wxUI.dialogs.mastodon import dialogs as mastodon_dialogs
log = logging.getLogger("controller.buffers.mastodon.notifications") log = logging.getLogger("controller.buffers.mastodon.notifications")
@ -46,6 +48,9 @@ class NotificationsBuffer(BaseBuffer):
def destroy_status(self, *args, **kwargs): def destroy_status(self, *args, **kwargs):
index = self.buffer.list.get_selected() index = self.buffer.list.get_selected()
item = self.session.db[self.name][index] item = self.session.db[self.name][index]
answer = mastodon_dialogs.delete_notification_dialog()
if answer == False:
return
items = self.session.db[self.name] items = self.session.db[self.name]
try: try:
self.session.api.notifications_dismiss(id=item.id) self.session.api.notifications_dismiss(id=item.id)
@ -54,4 +59,5 @@ class NotificationsBuffer(BaseBuffer):
output.speak(_("Notification dismissed.")) output.speak(_("Notification dismissed."))
except Exception as e: except Exception as e:
self.session.sound.play("error.ogg") self.session.sound.play("error.ogg")
log.exception("")
self.session.db[self.name] = items self.session.db[self.name] = items

View File

@ -18,6 +18,14 @@ def delete_post_dialog():
dlg.Destroy() dlg.Destroy()
return result 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(): def clear_list():
result = False 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) 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)