feat: add followers/following list
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user