mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-17 21:56:07 -04:00
Feat: Added muting posts.
This commit is contained in:
@@ -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")
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user