Feat: Added muting posts.

This commit is contained in:
Manuel Cortez 2024-05-17 16:38:26 -06:00
parent aee2a3b8b2
commit 2a1d86f917
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 30 additions and 0 deletions

View File

@ -8,6 +8,7 @@ TWBlue Changelog
* TWBlue should be able to switch to Windows 11 Keymap when running under Windows 11. ([#494](https://github.com/mcv-software/twblue/issues/494))
* Mastodon:
* When viewing a post, a button displays the number of boosts and times it has been added to favorites. Clicking on that button will open a list of users who have interacted with the post. From that list, it is possible to view profiles and perform common user actions.
* Now it is possible to mute conversations in Mastodon sessions. To do this, there is a button that can be called "Mute" or "Unmute Conversation" in the dialog to display the post. Conversations that have been muted will not generate notifications or mentions when they receive new replies. Only conversations that you are a part of can be muted.
* Fixed an error that caused TWBlue to be unable to properly display the user action dialog from the followers or following buffer. ([#575](https://github.com/mcv-software/twblue/issues/575))
## changes in version 2024.01.05

View File

@ -6,6 +6,7 @@ import widgetUtils
import config
import output
from twitter_text import parse_tweet, config
from mastodon import MastodonError
from controller import messages
from sessions.mastodon import templates
from wxUI.dialogs.mastodon import postDialogs
@ -257,6 +258,13 @@ class viewPost(post):
else:
source = source_obj.get("name")
self.message = postDialogs.viewPost(text=text, boosts_count=boost_count, favs_count=favs_count, source=source, date=date, privacy=privacy)
participants = [post.account.id] + [account.id for account in post.mentions]
print(post, participants)
if self.session.db["user_id"] in participants:
self.message.mute.Enable(True)
if post.muted:
self.message.mute.SetLabel(_("Unmute conversation"))
widgetUtils.connect_event(self.message.mute, widgetUtils.BUTTON_PRESSED, self.mute_unmute)
self.message.SetTitle(title)
if image_description != "":
self.message.image_description.Enable(True)
@ -275,6 +283,24 @@ class viewPost(post):
def text_processor(self):
pass
def mute_unmute(self, *args, **kwargs):
post = self.session.api.status(self.post_id)
if post.muted == True:
action = "status_unmute"
new_label = _("Mute conversation")
msg = _("Conversation unmuted.")
else:
action = "status_mute"
new_label = _("Unmute conversation")
msg = _("Conversation muted.")
try:
getattr(self.session.api, action)(self.post_id)
self.message.mute.SetLabel(new_label)
output.speak(msg)
except MastodonError:
return
def on_boosts(self, *args, **kwargs):
users = self.session.api.status_reblogged_by(self.post_id)
title = _("people who boosted this post")

View File

@ -228,12 +228,15 @@ class viewPost(wx.Dialog):
def create_buttons_section(self, panel):
sizer = wx.BoxSizer(wx.HORIZONTAL)
self.mute = wx.Button(panel, wx.ID_ANY, _("Mute conversation"))
self.mute.Enable(False)
self.share = wx.Button(panel, wx.ID_ANY, _("Copy link to clipboard"))
self.share.Enable(False)
self.spellcheck = wx.Button(panel, wx.ID_ANY, _("Check &spelling..."))
self.translateButton = wx.Button(panel, wx.ID_ANY, _("&Translate..."))
cancelButton = wx.Button(panel, wx.ID_CANCEL, _("C&lose"))
cancelButton.SetDefault()
sizer.Add(self.mute, 0, wx.ALL, 5)
sizer.Add(self.share, 0, wx.ALL, 5)
sizer.Add(self.spellcheck, 0, wx.ALL, 5)
sizer.Add(self.translateButton, 0, wx.ALL, 5)