From 45377648c1d5f4987d68b2d70769151bacbb70f1 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 22 Feb 2026 14:52:11 +0000 Subject: [PATCH] Fix follower links, HTMX follow/unfollow, update shared submodule - Follower profile links now go to https://domain/@username (web profile) instead of the AP actor URL which 404s - Follow Back/Unfollow buttons update via HTMX without full page refresh - Update shared submodule to decoupling branch with new protocol methods Co-Authored-By: Claude Opus 4.6 --- bp/social/routes.py | 28 ++++++++++++++ shared | 2 +- templates/federation/_actor_list_items.html | 41 ++++++++++----------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/bp/social/routes.py b/bp/social/routes.py index 32a36a0..04c0d99 100644 --- a/bp/social/routes.py +++ b/bp/social/routes.py @@ -157,6 +157,8 @@ def register(url_prefix="/social"): await services.federation.send_follow( g.s, actor.preferred_username, remote_actor_url, ) + if request.headers.get("HX-Request"): + return await _actor_card_response(actor, remote_actor_url, is_followed=True) return redirect(request.referrer or url_for("social.search")) @bp.post("/unfollow") @@ -168,8 +170,34 @@ def register(url_prefix="/social"): await services.federation.unfollow( g.s, actor.preferred_username, remote_actor_url, ) + if request.headers.get("HX-Request"): + return await _actor_card_response(actor, remote_actor_url, is_followed=False) return redirect(request.referrer or url_for("social.search")) + async def _actor_card_response(actor, remote_actor_url, is_followed): + """Re-render a single actor card after follow/unfollow via HTMX.""" + remote_dto = await services.federation.get_or_fetch_remote_actor( + g.s, remote_actor_url, + ) + if not remote_dto: + return Response("", status=200) + followed_urls = {remote_actor_url} if is_followed else set() + # Detect list context from referer + referer = request.referrer or "" + if "/followers" in referer: + list_type = "followers" + else: + list_type = "following" + return await render_template( + "federation/_actor_list_items.html", + actors=[remote_dto], + total=0, + page=1, + list_type=list_type, + followed_urls=followed_urls, + actor=actor, + ) + # -- Interactions --------------------------------------------------------- @bp.post("/like") diff --git a/shared b/shared index bccfff0..04f7c5e 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit bccfff0c699fdf9e3ee7c911af1f17a5294943f6 +Subproject commit 04f7c5e85c647dbffdf46fd80ca69473c0a988cd diff --git a/templates/federation/_actor_list_items.html b/templates/federation/_actor_list_items.html index bbe445b..1704012 100644 --- a/templates/federation/_actor_list_items.html +++ b/templates/federation/_actor_list_items.html @@ -1,5 +1,6 @@ {% for a in actors %} -
+
{% if a.icon_url %} {% else %} @@ -14,7 +15,7 @@ {{ a.display_name or a.preferred_username }} {% else %} - + {{ a.display_name or a.preferred_username }} {% endif %} @@ -26,32 +27,28 @@ {% if actor %}
- {% if list_type == "following" %} -
+ {% if list_type == "following" or a.actor_url in (followed_urls or set()) %} +
- {% elif list_type == "followers" %} - {% if a.actor_url in followed_urls %} -
- - - -
- {% else %} -
- - - -
- {% endif %} + {% else %} +
+ + + +
{% endif %}
{% endif %}