sforkowany z mirror/soapbox
Chats: Create next link if not provided
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>strip-front-mentions
rodzic
12e4c6c083
commit
53497c2132
|
@ -35,7 +35,11 @@ export function fetchChats() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: CHATS_FETCH_REQUEST });
|
dispatch({ type: CHATS_FETCH_REQUEST });
|
||||||
api(getState).get('/api/v2/pleroma/chats').then((response) => {
|
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 });
|
dispatch({ type: CHATS_FETCH_SUCCESS, chats: response.data, next: next ? next.uri : null });
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
Ładowanie…
Reference in New Issue