mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-18 06:06:06 -04:00
Feat: display users who boosted or favorited a post.
This commit is contained in:
@@ -550,7 +550,7 @@ class BaseBuffer(base.Buffer):
|
||||
output.speak(_("No status found with that ID"))
|
||||
return
|
||||
# print(post)
|
||||
msg = messages.viewPost(item, offset_hours=self.session.db["utc_offset"], item_url=self.get_item_url(item=item))
|
||||
msg = messages.viewPost(self.session, item, offset_hours=self.session.db["utc_offset"], item_url=self.get_item_url(item=item))
|
||||
|
||||
def ocr_image(self):
|
||||
post = self.get_item()
|
||||
|
@@ -10,6 +10,7 @@ from controller import messages
|
||||
from sessions.mastodon import templates
|
||||
from wxUI.dialogs.mastodon import postDialogs
|
||||
from extra.autocompletionUsers import completion
|
||||
from . import userList
|
||||
|
||||
def character_count(post_text, post_cw, character_limit=500):
|
||||
# We will use text for counting character limit only.
|
||||
@@ -235,9 +236,11 @@ class post(messages.basicMessage):
|
||||
self.message.visibility.SetSelection(setting)
|
||||
|
||||
class viewPost(post):
|
||||
def __init__(self, post, offset_hours=0, date="", item_url=""):
|
||||
def __init__(self, session, post, offset_hours=0, date="", item_url=""):
|
||||
self.session = session
|
||||
if post.reblog != None:
|
||||
post = post.reblog
|
||||
self.post_id = post.id
|
||||
author = post.account.display_name if post.account.display_name != "" else post.account.username
|
||||
title = _(u"Post from {}").format(author)
|
||||
image_description = templates.process_image_descriptions(post.media_attachments)
|
||||
@@ -264,12 +267,24 @@ class viewPost(post):
|
||||
widgetUtils.connect_event(self.message.share, widgetUtils.BUTTON_PRESSED, self.share)
|
||||
self.item_url = item_url
|
||||
widgetUtils.connect_event(self.message.translateButton, widgetUtils.BUTTON_PRESSED, self.translate)
|
||||
widgetUtils.connect_event(self.message.boosts_button, widgetUtils.BUTTON_PRESSED, self.on_boosts)
|
||||
widgetUtils.connect_event(self.message.favorites_button, widgetUtils.BUTTON_PRESSED, self.on_favorites)
|
||||
self.message.ShowModal()
|
||||
|
||||
# We won't need text_processor in this dialog, so let's avoid it.
|
||||
def text_processor(self):
|
||||
pass
|
||||
|
||||
def on_boosts(self, *args, **kwargs):
|
||||
users = self.session.api.status_reblogged_by(self.post_id)
|
||||
title = _("people who boosted this post")
|
||||
user_list = userList.MastodonUserList(session=self.session, users=users, title=title)
|
||||
|
||||
def on_favorites(self, *args, **kwargs):
|
||||
users = self.session.api.status_favourited_by(self.post_id)
|
||||
title = _("people who favorited this post")
|
||||
user_list = userList.MastodonUserList(session=self.session, users=users, title=title)
|
||||
|
||||
def share(self, *args, **kwargs):
|
||||
if hasattr(self, "item_url"):
|
||||
output.copy(self.item_url)
|
||||
|
25
src/controller/mastodon/userList.py
Normal file
25
src/controller/mastodon/userList.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mastodon import MastodonError
|
||||
from wxUI.dialogs.mastodon import showUserProfile
|
||||
from controller.userList import UserListController
|
||||
from . import userActions
|
||||
|
||||
class MastodonUserList(UserListController):
|
||||
|
||||
def process_users(self, users):
|
||||
return [dict(id=user.id, display_name=f"{user.display_name} (@{user.acct})", acct=user.acct) for user in users]
|
||||
|
||||
def on_actions(self, *args, **kwargs):
|
||||
user = self.dialog.user_list.GetSelection()
|
||||
user_account = self.users[user]
|
||||
u = userActions.userActions(self.session, [user_account.get("acct")])
|
||||
|
||||
def on_details(self, *args, **kwargs):
|
||||
user = self.dialog.user_list.GetSelection()
|
||||
user_id = self.users[user].get("id")
|
||||
try:
|
||||
user_object = self.session.api.account(user_id)
|
||||
except MastodonError:
|
||||
return
|
||||
dlg = showUserProfile.ShowUserProfile(user_object)
|
||||
dlg.ShowModal()
|
23
src/controller/userList.py
Normal file
23
src/controller/userList.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import widgetUtils
|
||||
from pubsub import pub
|
||||
from wxUI.dialogs import userList
|
||||
|
||||
class UserListController(object):
|
||||
def __init__(self, users, session, title):
|
||||
super(UserListController, self).__init__()
|
||||
self.session = session
|
||||
self.users = self.process_users(users)
|
||||
self.dialog = userList.UserListDialog(title=title, users=[user.get("display_name", user.get("acct")) for user in self.users])
|
||||
widgetUtils.connect_event(self.dialog.actions_button, widgetUtils.BUTTON_PRESSED, self.on_actions)
|
||||
widgetUtils.connect_event(self.dialog.details_button, widgetUtils.BUTTON_PRESSED, self.on_details)
|
||||
self.dialog.ShowModal()
|
||||
|
||||
def process_users(self, users):
|
||||
return {}
|
||||
|
||||
def on_actions(self):
|
||||
pass
|
||||
|
||||
def on_details(self, *args, **kwargs):
|
||||
pass
|
Reference in New Issue
Block a user