fix: user post feed view
This commit is contained in:
+27
-8
@@ -206,6 +206,22 @@ export type Feedback = {
|
||||
|
||||
// ─── Posts ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** Keyset cursor for the scroll feed — the last seen post's sort key. */
|
||||
export type FeedCursor = { created_at: string; id: string };
|
||||
|
||||
/** Paging options for a scroll feed: a keyset `before` cursor (preferred) or
|
||||
* a plain `limit` for the first/grid page. */
|
||||
export type FeedPageParams = { limit?: number; before?: FeedCursor };
|
||||
|
||||
function feedPageQuery({ limit = 20, before }: FeedPageParams): string {
|
||||
const qs = new URLSearchParams({ limit: String(limit) });
|
||||
if (before) {
|
||||
qs.set("before", before.created_at);
|
||||
qs.set("before_id", before.id);
|
||||
}
|
||||
return `?${qs}`;
|
||||
}
|
||||
|
||||
export const posts = {
|
||||
create(input: {
|
||||
caption: string;
|
||||
@@ -271,8 +287,10 @@ export const posts = {
|
||||
body: JSON.stringify({ image_urls }),
|
||||
});
|
||||
},
|
||||
mine() {
|
||||
return call<Post[]>("/posts/mine");
|
||||
/** The caller's own posts (scroll feed). With `before` it keyset-pages
|
||||
* posts older than that cursor; without it, the newest page. */
|
||||
mine(opts: FeedPageParams = {}) {
|
||||
return call<Post[]>(`/posts/mine${feedPageQuery(opts)}`);
|
||||
},
|
||||
/** The caller's hidden posts (owner-only) — drives the /u/me Hidden tab. */
|
||||
hidden() {
|
||||
@@ -549,12 +567,13 @@ export const profile = {
|
||||
get(handle: string) {
|
||||
return call<PublicProfile>(`/u/${encodeURIComponent(handle)}`);
|
||||
},
|
||||
feed(handle: string, limit = 20, offset = 0) {
|
||||
const qs = new URLSearchParams({
|
||||
limit: String(limit),
|
||||
offset: String(offset),
|
||||
});
|
||||
return call<Post[]>(`/u/${encodeURIComponent(handle)}/feed?${qs}`);
|
||||
/** A user's public scroll feed. With `before` it keyset-pages posts older
|
||||
* than that cursor (infinite scroll); otherwise the newest page. The grid
|
||||
* still passes plain `limit`. */
|
||||
feed(handle: string, opts: FeedPageParams = {}) {
|
||||
return call<Post[]>(
|
||||
`/u/${encodeURIComponent(handle)}/feed${feedPageQuery(opts)}`,
|
||||
);
|
||||
},
|
||||
/** Posts that tag this user (the Mentions tab), newest first. */
|
||||
mentionsFeed(handle: string, limit = 30, offset = 0) {
|
||||
|
||||
Reference in New Issue
Block a user