From 53497c2132eb28a5272d8b9a90067e47335a3888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 14 Dec 2021 13:25:08 +0100 Subject: [PATCH] Chats: Create next link if not provided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/chats.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/soapbox/actions/chats.js b/app/soapbox/actions/chats.js index 5407fa769..f89b97fdb 100644 --- a/app/soapbox/actions/chats.js +++ b/app/soapbox/actions/chats.js @@ -35,7 +35,11 @@ export function fetchChats() { return (dispatch, getState) => { dispatch({ type: CHATS_FETCH_REQUEST }); api(getState).get('/api/v2/pleroma/chats').then((response) => { - const next = getLinks(response).refs.find(link => link.rel === 'next'); + let next = getLinks(response).refs.find(link => link.rel === 'next'); + + if (!next && response.data.length) { + next = { uri: `/api/v2/pleroma/chats?max_id=${response.data[response.data.length - 1].id}&offset=0` }; + } dispatch({ type: CHATS_FETCH_SUCCESS, chats: response.data, next: next ? next.uri : null }); }).catch(error => {