Mastodon: Dismiss notifications from GUI or invisible interface (by using the keystroke to delete an item in current buffer)

This commit is contained in:
Manuel Cortez 2022-12-19 16:21:50 -06:00
parent 1eb9aefbf1
commit b8647c29ea
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790

View File

@ -32,6 +32,7 @@ class NotificationsBuffer(BaseBuffer):
def bind_events(self): def bind_events(self):
widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event) widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.post) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.post)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.destroy_status, self.buffer.dismiss)
def fav(self): def fav(self):
pass pass
@ -41,3 +42,16 @@ class NotificationsBuffer(BaseBuffer):
def can_share(self): def can_share(self):
return False return False
def destroy_status(self, *args, **kwargs):
index = self.buffer.list.get_selected()
item = self.session.db[self.name][index]
items = self.session.db[self.name]
try:
self.session.api.notifications_dismiss(id=item.id)
items.pop(index)
self.buffer.list.remove_item(index)
output.speak(_("Notification dismissed."))
except Exception as e:
self.session.sound.play("error.ogg")
self.session.db[self.name] = items