From 65aea3c43cae55036103f3190493b24ba02524d5 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 5 Apr 2023 09:39:39 -0600 Subject: [PATCH] Mastodon: Change buffer title properly after timelines are loaded during startup --- doc/changelog.md | 1 + src/controller/buffers/mastodon/base.py | 1 + src/controller/buffers/mastodon/users.py | 6 ++++++ src/controller/mainController.py | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/doc/changelog.md b/doc/changelog.md index 37b94d82..f7a04c6b 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -10,6 +10,7 @@ During the development of the current TWBlue version, Twitter has cut out access * Implemented "Hide emojis on usernames" in both GUI and invisible interface. * Added an experimental feature to recover from connection errors. When making a post, if the post cannot be published due to any kind of error, TWBlue will bring up the dialog where the post was composed, so you can give the post a second chance or save the post's text. This feature should work for threads, posts with attachments, polls and replies. ([#527,](https://github.com/MCV-Software/TWBlue/issues/527) [#526,](https://github.com/MCV-Software/TWBlue/issues/526) [#377,](https://github.com/MCV-Software/TWBlue/issues/377) [#137,](https://github.com/MCV-Software/TWBlue/issues/137) [#108](https://github.com/MCV-Software/TWBlue/issues/108)) * Fixed an error on mentions buffer that was making TWBlue unable to load posts if there were mentions from a blocked or deleted account. + * Fixed an error when loading timelines during startup where TWBlue was unable to change the buffer title properly. ## Changes on version 2023.2.6 diff --git a/src/controller/buffers/mastodon/base.py b/src/controller/buffers/mastodon/base.py index a169c865..994c544a 100644 --- a/src/controller/buffers/mastodon/base.py +++ b/src/controller/buffers/mastodon/base.py @@ -119,6 +119,7 @@ class BaseBuffer(base.Buffer): if hasattr(self, "finished_timeline") and self.finished_timeline == False: if "-timeline" in self.name: self.username = self.session.db[self.name][0]["account"].username + pub.sendMessage("core.change_buffer_title", name=self.session.get_name(), buffer=self.name, title=_("Timeline for {}").format(self.username)) self.finished_timeline = True self.put_items_on_list(number_of_items) if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: diff --git a/src/controller/buffers/mastodon/users.py b/src/controller/buffers/mastodon/users.py index 5463017f..af2c8d59 100644 --- a/src/controller/buffers/mastodon/users.py +++ b/src/controller/buffers/mastodon/users.py @@ -4,6 +4,7 @@ import logging import wx import widgetUtils import output +from pubsub import pub from mysc.thread_utils import call_threaded from controller.buffers.mastodon.base import BaseBuffer from controller.mastodon import messages @@ -88,6 +89,11 @@ class UserBuffer(BaseBuffer): if hasattr(self, "finished_timeline") and self.finished_timeline == False: if "-followers" in self.name or "-following" in self.name: self.username = self.session.api.account(id=self.kwargs.get("id")).username + if "-followers" in self.name: + title=_("Followers for {}").format(self.username) + else: + title=_("Following for {}").format(self.username) + pub.sendMessage("core.change_buffer_title", name=self.session.get_name(), buffer=self.name, title=title) self.finished_timeline = True self.put_items_on_list(number_of_items) if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 192d3cc1..f33717ff 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -105,6 +105,7 @@ class Controller(object): pub.subscribe(self.toggle_share_settings, "toggleShare") pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed") pub.subscribe(self.create_account_buffer, "core.create_account") + pub.subscribe(self.change_buffer_title, "core.change_buffer_title") # Mastodon specific events. pub.subscribe(self.mastodon_new_item, "mastodon.new_item") @@ -1075,6 +1076,11 @@ class Controller(object): if home != None: wx.CallAfter(home.post_from_error, visibility=visibility, reply_to=reply_to, data=posts) + def change_buffer_title(self, name, buffer, title): + buffer_index = self.view.search(buffer, name) + if buffer_index != None and buffer_index > -1: + self.view.set_page_title(buffer_index, title) + def report_error(self, *args, **kwargs): """Redirects the user to the issue page on github""" log.debug("Redirecting the user to report an error...")