feat: update dependencies to k-ap v0.1.7 and add profileHref utility for user links

This commit is contained in:
2026-05-27 23:37:22 +02:00
parent 6f65742284
commit f6893b19dc
18 changed files with 254 additions and 224 deletions

View File

@@ -1,3 +1,4 @@
import { cache } from "react";
import { z } from "zod";
export const UserSchema = z.object({
@@ -278,13 +279,14 @@ export const markAllNotificationsRead = (token: string) =>
token
);
export const lookupRemoteActor = (handle: string, token: string | null) =>
export const lookupRemoteActor = cache((handle: string, token: string | null) =>
apiFetch(
`/users/lookup?handle=${encodeURIComponent(handle)}`,
{ next: { tags: [`remote-actor:${handle}`] } },
RemoteActorSchema,
token
);
)
);
export const getRemoteActorPosts = (
handle: string,

View File

@@ -17,6 +17,14 @@ export function fullFediverseHandle(handle: string, actorUrl: string): string {
}
}
/** Returns the correct profile URL for an author.
* Local users go to /users/:username; remote actors go to /remote-actor?handle=. */
export function profileHref(username: string, local: boolean): string {
if (local) return `/users/${username}`;
const handle = username.startsWith("@") ? username : `@${username}`;
return `/remote-actor?handle=${encodeURIComponent(handle)}`;
}
export function buildThoughtThreads(thoughts: Thought[]): ThoughtThreadType[] {
const thoughtMap = new Map<string, Thought>();
thoughts.forEach((t) => thoughtMap.set(t.id, t));