Mastodon: Change buffer title properly after timelines are loaded during startup

This commit is contained in:
Manuel Cortez 2023-04-05 09:39:39 -06:00
parent 972b851b93
commit 65aea3c43c
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
4 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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...")