mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-03-06 01:17:32 +01:00
Arreglado ver perfil.
This commit is contained in:
@@ -333,6 +333,33 @@ class Handler:
|
||||
return
|
||||
self._open_user_list(main_controller, session, actor, handle, list_type="following")
|
||||
|
||||
async def open_user_timeline(self, main_controller, session, user_payload=None):
|
||||
"""Open posts timeline for a user (Alt+Win+I)."""
|
||||
actor, handle = self._resolve_actor(session, user_payload)
|
||||
if not actor:
|
||||
output.speak(_("No user selected."), True)
|
||||
return
|
||||
|
||||
account_name = session.get_name()
|
||||
list_name = f"{handle}-timeline"
|
||||
if main_controller.search_buffer(list_name, account_name):
|
||||
index = main_controller.view.search(list_name, account_name)
|
||||
if index is not None:
|
||||
main_controller.view.change_buffer(index)
|
||||
return
|
||||
|
||||
title = _("Timeline for {user}").format(user=handle)
|
||||
from pubsub import pub
|
||||
pub.sendMessage(
|
||||
"createBuffer",
|
||||
buffer_type="UserTimeline",
|
||||
session_type="blueski",
|
||||
buffer_title=title,
|
||||
parent_tab=main_controller.view.search(account_name, account_name),
|
||||
start=True,
|
||||
kwargs=dict(parent=main_controller.view.nb, name=list_name, session=session, actor=actor)
|
||||
)
|
||||
|
||||
def _resolve_actor(self, session, user_payload):
|
||||
def g(obj, key, default=None):
|
||||
if isinstance(obj, dict):
|
||||
|
||||
@@ -7,6 +7,7 @@ from .timeline import (
|
||||
LikesBuffer,
|
||||
MentionsBuffer,
|
||||
SentBuffer,
|
||||
UserTimeline,
|
||||
SearchBuffer,
|
||||
)
|
||||
from .user import FollowersBuffer, FollowingBuffer, BlocksBuffer
|
||||
|
||||
@@ -319,6 +319,45 @@ class SentBuffer(BaseBuffer):
|
||||
return 0
|
||||
|
||||
|
||||
class UserTimeline(BaseBuffer):
|
||||
"""Buffer for posts by a specific user."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.actor = kwargs.get("actor")
|
||||
super(UserTimeline, self).__init__(*args, **kwargs)
|
||||
self.type = "user_timeline"
|
||||
|
||||
def create_buffer(self, parent, name):
|
||||
self.buffer = BlueskiPanels.HomePanel(parent, name)
|
||||
self.buffer.session = self.session
|
||||
|
||||
def start_stream(self, mandatory=False, play_sound=True):
|
||||
if not self.actor:
|
||||
return 0
|
||||
|
||||
count = 50
|
||||
try:
|
||||
count = self.session.settings["general"].get("max_posts_per_call", 50)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
api = self.session._ensure_client()
|
||||
if not api:
|
||||
return 0
|
||||
|
||||
try:
|
||||
res = api.app.bsky.feed.get_author_feed({
|
||||
"actor": self.actor,
|
||||
"limit": count,
|
||||
})
|
||||
items = getattr(res, "feed", []) or []
|
||||
except Exception:
|
||||
log.exception("Error fetching user timeline")
|
||||
return 0
|
||||
|
||||
return self.process_items(list(items), play_sound)
|
||||
|
||||
|
||||
class SearchBuffer(BaseBuffer):
|
||||
"""Buffer for search results (posts)."""
|
||||
|
||||
|
||||
@@ -404,6 +404,8 @@ class Controller(object):
|
||||
"ConversationListBuffer": BlueskiChats.ConversationListBuffer,
|
||||
"ChatMessageBuffer": BlueskiChats.ChatBuffer,
|
||||
"chat_messages": BlueskiChats.ChatBuffer,
|
||||
"UserTimeline": BlueskiTimelines.UserTimeline,
|
||||
"user_timeline": BlueskiTimelines.UserTimeline,
|
||||
}
|
||||
|
||||
buffer_panel_class = buffer_map.get(buffer_type)
|
||||
|
||||
@@ -283,6 +283,13 @@ class ShowUserProfileDialog(wx.Dialog):
|
||||
return obj.get(key, default)
|
||||
return getattr(obj, key, default)
|
||||
|
||||
def get_count(*keys):
|
||||
for k in keys:
|
||||
val = g(profile_model, k)
|
||||
if val is not None:
|
||||
return val
|
||||
return None
|
||||
|
||||
return {
|
||||
"did": g(profile_model, "did"),
|
||||
"handle": g(profile_model, "handle"),
|
||||
@@ -290,9 +297,9 @@ class ShowUserProfileDialog(wx.Dialog):
|
||||
"description": g(profile_model, "description"),
|
||||
"avatar": g(profile_model, "avatar"),
|
||||
"banner": g(profile_model, "banner"),
|
||||
"followersCount": g(profile_model, "followersCount"),
|
||||
"followsCount": g(profile_model, "followsCount"),
|
||||
"postsCount": g(profile_model, "postsCount"),
|
||||
"followersCount": get_count("followersCount", "followers_count"),
|
||||
"followsCount": get_count("followsCount", "follows_count", "followingCount", "following_count"),
|
||||
"postsCount": get_count("postsCount", "posts_count"),
|
||||
"viewer": g(profile_model, "viewer") or {},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user