Set updated statuses also in GUI

This commit is contained in:
Manuel Cortez 2022-11-25 17:43:03 -06:00
parent d177ef5be2
commit 5bbf069d61
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 17 additions and 4 deletions

View File

@ -210,6 +210,10 @@ class BaseBuffer(base.Buffer):
if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
output.speak(" ".join(post[:2]), speech=self.session.settings["reporting"]["speech_reporting"], braille=self.session.settings["reporting"]["braille_reporting"]) output.speak(" ".join(post[:2]), speech=self.session.settings["reporting"]["speech_reporting"], braille=self.session.settings["reporting"]["braille_reporting"])
def update_item(self, item, position):
post = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.list.SetItem(position, 1, post[1])
def bind_events(self): def bind_events(self):
log.debug("Binding events...") log.debug("Binding events...")
self.buffer.set_focus_function(self.onFocus) self.buffer.set_focus_function(self.onFocus)

View File

@ -128,6 +128,7 @@ class Controller(object):
# Mastodon specific events. # Mastodon specific events.
pub.subscribe(self.mastodon_new_item, "mastodon.new_item") pub.subscribe(self.mastodon_new_item, "mastodon.new_item")
pub.subscribe(self.mastodon_updated_item, "mastodon.updated_item")
pub.subscribe(self.mastodon_new_conversation, "mastodon.conversation_received") pub.subscribe(self.mastodon_new_conversation, "mastodon.conversation_received")
# connect application events to GUI # connect application events to GUI
@ -1243,6 +1244,14 @@ class Controller(object):
if sound_to_play != None and buff not in buffer.session.settings["other_buffers"]["muted_buffers"]: if sound_to_play != None and buff not in buffer.session.settings["other_buffers"]["muted_buffers"]:
self.notify(buffer.session, sound_to_play) self.notify(buffer.session, sound_to_play)
def mastodon_updated_item(self, item, session_name, _buffers):
sound_to_play = None
for buff in _buffers.keys():
buffer = self.search_buffer(buff, session_name)
if buffer == None or buffer.session.get_name() != session_name:
return
buffer.update_item(item, _buffers[buff])
# Normally, we'd define this function on mastodon's session, but we need to access conversationListBuffer and here is the best place to do so. # Normally, we'd define this function on mastodon's session, but we need to access conversationListBuffer and here is the best place to do so.
def mastodon_new_conversation(self, conversation, session_name): def mastodon_new_conversation(self, conversation, session_name):
buffer = self.search_buffer("direct_messages", session_name) buffer = self.search_buffer("direct_messages", session_name)

View File

@ -160,7 +160,7 @@ class Session(base.baseSession):
item_position = next((x for x in range(len(items)) if items[x].id == item.id), None) item_position = next((x for x in range(len(items)) if items[x].id == item.id), None)
if item_position != None: if item_position != None:
self.db[name][item_position] = item self.db[name][item_position] = item
return True return item_position
return False return False
def api_call(self, call_name, action="", _sound=None, report_success=False, report_failure=True, preexec_message="", *args, **kwargs): def api_call(self, call_name, action="", _sound=None, report_success=False, report_failure=True, preexec_message="", *args, **kwargs):
@ -264,11 +264,11 @@ class Session(base.baseSession):
# Discard processing the status if the streaming sends a tweet for another account. # Discard processing the status if the streaming sends a tweet for another account.
if self.get_name() != session_name: if self.get_name() != session_name:
return return
buffers = [] buffers = {}
for b in list(self.db.keys()): for b in list(self.db.keys()):
updated = self.update_item(b, status) updated = self.update_item(b, status)
if updated: if updated != False:
buffers.append(b) buffers[b] = updated
pub.sendMessage("mastodon.updated_item", session_name=self.get_name(), item=status, _buffers=buffers) pub.sendMessage("mastodon.updated_item", session_name=self.get_name(), item=status, _buffers=buffers)
def on_notification(self, notification, session_name): def on_notification(self, notification, session_name):