mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Set updated statuses also in GUI
This commit is contained in:
parent
d177ef5be2
commit
5bbf069d61
@ -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:
|
||||
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):
|
||||
log.debug("Binding events...")
|
||||
self.buffer.set_focus_function(self.onFocus)
|
||||
|
@ -128,6 +128,7 @@ class Controller(object):
|
||||
|
||||
# Mastodon specific events.
|
||||
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")
|
||||
|
||||
# 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"]:
|
||||
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.
|
||||
def mastodon_new_conversation(self, conversation, session_name):
|
||||
buffer = self.search_buffer("direct_messages", session_name)
|
||||
|
@ -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)
|
||||
if item_position != None:
|
||||
self.db[name][item_position] = item
|
||||
return True
|
||||
return item_position
|
||||
return False
|
||||
|
||||
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.
|
||||
if self.get_name() != session_name:
|
||||
return
|
||||
buffers = []
|
||||
buffers = {}
|
||||
for b in list(self.db.keys()):
|
||||
updated = self.update_item(b, status)
|
||||
if updated:
|
||||
buffers.append(b)
|
||||
if updated != False:
|
||||
buffers[b] = updated
|
||||
pub.sendMessage("mastodon.updated_item", session_name=self.get_name(), item=status, _buffers=buffers)
|
||||
|
||||
def on_notification(self, notification, session_name):
|
||||
|
Loading…
Reference in New Issue
Block a user