feat: add followers/following list

This commit is contained in:
gosangam
2026-06-09 13:20:44 +05:30
parent ef6e280524
commit e36afdd1a5
5 changed files with 380 additions and 8 deletions
+38
View File
@@ -493,4 +493,42 @@ export const relationships = {
body: JSON.stringify({ category, reason }),
});
},
/** One page of the profile's accepted followers, optionally filtered by a
* name/handle search. `total` is the full matching count for pagination. */
followers(handle: string, opts: FollowListParams = {}) {
return call<FollowList>(
`/u/${encodeURIComponent(handle)}/followers?${followListQuery(opts)}`,
);
},
/** One page of the users this profile follows (accepted), same shape. */
following(handle: string, opts: FollowListParams = {}) {
return call<FollowList>(
`/u/${encodeURIComponent(handle)}/following?${followListQuery(opts)}`,
);
},
};
/** Lightweight user row in a followers / following list. */
export type UserSummary = {
handle: string;
name: string;
avatar_url: string | null;
};
/** A paginated followers/following page: the rows + total matching count. */
export type FollowList = {
users: UserSummary[];
total: number;
};
export type FollowListParams = { q?: string; limit?: number; offset?: number };
function followListQuery({ q, limit = 30, offset = 0 }: FollowListParams) {
const params = new URLSearchParams({
limit: String(limit),
offset: String(offset),
});
if (q && q.trim()) params.set("q", q.trim());
return params.toString();
}