From ffb8270b3c432c57fddd30d0ee168e6dbb3e012b Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 2 Dec 2021 01:23:01 +0000 Subject: [PATCH] Enable pagination on home timeline --- src/api/posts.ts | 15 +++++++++++++-- src/views/PostList.vue | 28 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/api/posts.ts b/src/api/posts.ts index 5c83a25..a1eb500 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -44,9 +44,20 @@ export interface Post { token_tx_id: string | null; } -export async function getPosts(authToken: string): Promise { +export async function getHomeTimeline( + authToken: string, + maxId?: string, +): Promise { const url = `${BACKEND_URL}/api/v1/timelines/home` - const response = await http(url, { authToken }) + let queryParams + if (maxId) { + queryParams = { max_id: maxId } + } + const response = await http(url, { + method: "GET", + queryParams, + authToken, + }) const data = await response.json() return data } diff --git a/src/views/PostList.vue b/src/views/PostList.vue index 8d88258..af7c1dd 100644 --- a/src/views/PostList.vue +++ b/src/views/PostList.vue @@ -3,6 +3,13 @@
+
@@ -11,13 +18,15 @@