timelines: bail early if there are no events

This commit is contained in:
Alex Gleason 2023-05-11 20:10:11 -05:00
parent af5420222b
commit 7820f88859
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 0 deletions

View File

@ -16,6 +16,10 @@ const homeController: AppController = async (c) => {
} }
const events = await getFeed(follows, { since, until }); const events = await getFeed(follows, { since, until });
if (!events.length) {
return c.json([]);
}
const statuses = (await Promise.all(events.map(toStatus))).filter(Boolean); const statuses = (await Promise.all(events.map(toStatus))).filter(Boolean);
const next = `${LOCAL_DOMAIN}/api/v1/timelines/home?until=${events[events.length - 1].created_at}`; const next = `${LOCAL_DOMAIN}/api/v1/timelines/home?until=${events[events.length - 1].created_at}`;