Chats: Create next link if not provided

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
merge-requests/911/head
marcin mikołajczak 2021-12-14 13:25:08 +01:00
rodzic 12e4c6c083
commit 53497c2132
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -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 => {