Arreglado ver perfil.

This commit is contained in:
Jesús Pavón Abián
2026-02-01 12:49:33 +01:00
parent d87d7ffcb5
commit 6a5e4407ac
5 changed files with 79 additions and 3 deletions

View File

@@ -333,6 +333,33 @@ class Handler:
return return
self._open_user_list(main_controller, session, actor, handle, list_type="following") 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 _resolve_actor(self, session, user_payload):
def g(obj, key, default=None): def g(obj, key, default=None):
if isinstance(obj, dict): if isinstance(obj, dict):

View File

@@ -7,6 +7,7 @@ from .timeline import (
LikesBuffer, LikesBuffer,
MentionsBuffer, MentionsBuffer,
SentBuffer, SentBuffer,
UserTimeline,
SearchBuffer, SearchBuffer,
) )
from .user import FollowersBuffer, FollowingBuffer, BlocksBuffer from .user import FollowersBuffer, FollowingBuffer, BlocksBuffer

View File

@@ -319,6 +319,45 @@ class SentBuffer(BaseBuffer):
return 0 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): class SearchBuffer(BaseBuffer):
"""Buffer for search results (posts).""" """Buffer for search results (posts)."""

View File

@@ -404,6 +404,8 @@ class Controller(object):
"ConversationListBuffer": BlueskiChats.ConversationListBuffer, "ConversationListBuffer": BlueskiChats.ConversationListBuffer,
"ChatMessageBuffer": BlueskiChats.ChatBuffer, "ChatMessageBuffer": BlueskiChats.ChatBuffer,
"chat_messages": BlueskiChats.ChatBuffer, "chat_messages": BlueskiChats.ChatBuffer,
"UserTimeline": BlueskiTimelines.UserTimeline,
"user_timeline": BlueskiTimelines.UserTimeline,
} }
buffer_panel_class = buffer_map.get(buffer_type) buffer_panel_class = buffer_map.get(buffer_type)

View File

@@ -283,6 +283,13 @@ class ShowUserProfileDialog(wx.Dialog):
return obj.get(key, default) return obj.get(key, default)
return getattr(obj, 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 { return {
"did": g(profile_model, "did"), "did": g(profile_model, "did"),
"handle": g(profile_model, "handle"), "handle": g(profile_model, "handle"),
@@ -290,9 +297,9 @@ class ShowUserProfileDialog(wx.Dialog):
"description": g(profile_model, "description"), "description": g(profile_model, "description"),
"avatar": g(profile_model, "avatar"), "avatar": g(profile_model, "avatar"),
"banner": g(profile_model, "banner"), "banner": g(profile_model, "banner"),
"followersCount": g(profile_model, "followersCount"), "followersCount": get_count("followersCount", "followers_count"),
"followsCount": g(profile_model, "followsCount"), "followsCount": get_count("followsCount", "follows_count", "followingCount", "following_count"),
"postsCount": g(profile_model, "postsCount"), "postsCount": get_count("postsCount", "posts_count"),
"viewer": g(profile_model, "viewer") or {}, "viewer": g(profile_model, "viewer") or {},
} }