More use of next link header on account (media) timelines (#3311)
This will reduce requests on who have only few statuses. - Use next link header to detect more items from first request - Omit next link header if result items are fewer than requested count (It had omit it only if result was empty before)
This commit is contained in:
parent
2241a15ee9
commit
cf4fe6cab8
3 changed files with 16 additions and 12 deletions
|
@ -115,7 +115,8 @@ export function fetchAccountTimeline(id, replace = false) {
|
|||
dispatch(fetchAccountTimelineRequest(id, skipLoading));
|
||||
|
||||
api(getState).get(`/api/v1/accounts/${id}/statuses`, { params }).then(response => {
|
||||
dispatch(fetchAccountTimelineSuccess(id, response.data, replace, skipLoading));
|
||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||
dispatch(fetchAccountTimelineSuccess(id, response.data, replace, skipLoading, next));
|
||||
}).catch(error => {
|
||||
dispatch(fetchAccountTimelineFail(id, error, skipLoading));
|
||||
});
|
||||
|
@ -138,7 +139,8 @@ export function fetchAccountMediaTimeline(id, replace = false) {
|
|||
dispatch(fetchAccountMediaTimelineRequest(id, skipLoading));
|
||||
|
||||
api(getState).get(`/api/v1/accounts/${id}/statuses`, { params }).then(response => {
|
||||
dispatch(fetchAccountMediaTimelineSuccess(id, response.data, replace, skipLoading));
|
||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||
dispatch(fetchAccountMediaTimelineSuccess(id, response.data, replace, skipLoading, next));
|
||||
}).catch(error => {
|
||||
dispatch(fetchAccountMediaTimelineFail(id, error, skipLoading));
|
||||
});
|
||||
|
@ -283,13 +285,14 @@ export function fetchAccountTimelineRequest(id, skipLoading) {
|
|||
};
|
||||
};
|
||||
|
||||
export function fetchAccountTimelineSuccess(id, statuses, replace, skipLoading) {
|
||||
export function fetchAccountTimelineSuccess(id, statuses, replace, skipLoading, next) {
|
||||
return {
|
||||
type: ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
||||
id,
|
||||
statuses,
|
||||
replace,
|
||||
skipLoading,
|
||||
next,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -311,13 +314,14 @@ export function fetchAccountMediaTimelineRequest(id, skipLoading) {
|
|||
};
|
||||
};
|
||||
|
||||
export function fetchAccountMediaTimelineSuccess(id, statuses, replace, skipLoading) {
|
||||
export function fetchAccountMediaTimelineSuccess(id, statuses, replace, skipLoading, next) {
|
||||
return {
|
||||
type: ACCOUNT_MEDIA_TIMELINE_FETCH_SUCCESS,
|
||||
id,
|
||||
statuses,
|
||||
replace,
|
||||
skipLoading,
|
||||
next,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue