diff --git a/apps/web/src/pages/admin/index.astro b/apps/web/src/pages/admin/index.astro index c01b6d5..65b021a 100644 --- a/apps/web/src/pages/admin/index.astro +++ b/apps/web/src/pages/admin/index.astro @@ -32,7 +32,7 @@ if (!feed) { const feedRes = await feed.handler({ ctx: Astro.locals.at, actorDid: DEFAULT_FEED_ACTOR, - cursor: new Date("2025-01-16").toISOString(), + //cursor: new Date("2025-01-16").toISOString(), //cursor: offset.toString(), search: query, }); diff --git a/packages/atproto/feeds/queries/following.ts b/packages/atproto/feeds/queries/following.ts index 934e22e..54f3485 100644 --- a/packages/atproto/feeds/queries/following.ts +++ b/packages/atproto/feeds/queries/following.ts @@ -17,7 +17,7 @@ export async function followingFeedHandler( const rpls = repostSubquery(args); const sqs = sqScores(ctx.db); - const dateField = sql`GREATEST(${rpls.created}, ${postTable.created})`; + const dateField = sql`GREATEST(${rpls.created}, ${postTable.created})`; const posts = await ctx.db .select({ id: postTable.id, @@ -45,6 +45,15 @@ export async function followingFeedHandler( .groupBy(postTable.id, rpls.created, rpls.repostUri) .offset(Number(cursor)); + let newCursor: string | undefined; + if (posts.length > 0) { + const lastPost = posts[posts.length - 1]; + if (!lastPost.date) { + throw new Error("wat!"); + } + newCursor = toCursor(new Date(lastPost.date)); + } + return { feed: posts.map((p) => ({ post: p.id, @@ -55,7 +64,6 @@ export async function followingFeedHandler( } : undefined, })), - cursor: - posts.length > 0 ? toCursor(posts[posts.length - 1].date) : undefined, + cursor: newCursor, }; }