this repo has no description
atproto bluesky typescript express

pagination improvements

+13 -7
+5 -3
src/lib/misc.ts
··· 1 1 import { AtpAgent } from "@atproto/api"; 2 2 3 - export async function getTimeline(agent: AtpAgent) { 4 - const response = await agent.getTimeline(); 5 - return response.data.feed; 3 + export async function getTimeline(agent: AtpAgent, cursor?: string) { 4 + const response = await agent.getTimeline({ 5 + cursor: cursor, 6 + }); 7 + return response.data; 6 8 } 7 9 8 10 export async function searchActors(agent: AtpAgent, q: string) {
+4 -2
src/routes/main.ts
··· 44 44 }); 45 45 46 46 router.get("/home", auth, async (req: Request, res: Response) => { 47 + const cursor = (req.query.cursor as string) || ""; 47 48 const handle = req.cookies.handle; 48 49 const did = await getActorDid(agent, handle); 49 50 const actor = await getActor(agent, did); 50 - const feed = await getTimeline(agent); 51 + const feed = await getTimeline(agent, cursor); 51 52 const follows = await getActorFollows(agent, did); 52 53 const { theme, bg } = await loadTheme(agent, did); 53 54 ··· 55 56 layout: "main", 56 57 title: "Bluesky / Home", 57 58 actor: actor, 58 - feed: feed, 59 + feed: feed.feed, 60 + cursor: feed.cursor, 59 61 follows: follows, 60 62 usertheme: theme, 61 63 bg: bg,
+4 -2
src/routes/mobile.ts
··· 30 30 }); 31 31 32 32 mobile.get("/home", auth, async (req: Request, res: Response) => { 33 - const feed = await getTimeline(agent); 33 + const cursor = (req.query.cursor as string) || ""; 34 + const feed = await getTimeline(agent, cursor); 34 35 35 36 res.render("mobile/home", { 36 37 layout: "mobile", 37 38 title: "Bluesky", 38 - feed: feed, 39 + feed: feed.feed, 40 + cursor: feed.cursor, 39 41 curuser: req.cookies.handle, 40 42 year: new Date().getFullYear(), 41 43 });