Smarter infinite scroll
This commit is contained in:
parent
1761d3f9c3
commit
d9022884c6
7 changed files with 74 additions and 24 deletions
|
@ -80,7 +80,7 @@ export function fetchAccount(id) {
|
|||
|
||||
export function fetchAccountTimeline(id, replace = false) {
|
||||
return (dispatch, getState) => {
|
||||
const ids = getState().getIn(['timelines', 'accounts_timelines', id], Immutable.List());
|
||||
const ids = getState().getIn(['timelines', 'accounts_timelines', id, 'items'], Immutable.List());
|
||||
const newestId = ids.size > 0 ? ids.first() : null;
|
||||
|
||||
let params = '';
|
||||
|
@ -103,11 +103,16 @@ export function fetchAccountTimeline(id, replace = false) {
|
|||
|
||||
export function expandAccountTimeline(id) {
|
||||
return (dispatch, getState) => {
|
||||
const lastId = getState().getIn(['timelines', 'accounts_timelines', id], Immutable.List()).last();
|
||||
const lastId = getState().getIn(['timelines', 'accounts_timelines', id, 'items'], Immutable.List()).last();
|
||||
|
||||
dispatch(expandAccountTimelineRequest(id));
|
||||
|
||||
api(getState).get(`/api/v1/accounts/${id}/statuses?max_id=${lastId}`).then(response => {
|
||||
api(getState).get(`/api/v1/accounts/${id}/statuses`, {
|
||||
params: {
|
||||
limit: 10,
|
||||
max_id: lastId
|
||||
}
|
||||
}).then(response => {
|
||||
dispatch(expandAccountTimelineSuccess(id, response.data));
|
||||
}).catch(error => {
|
||||
dispatch(expandAccountTimelineFail(id, error));
|
||||
|
|
|
@ -9,7 +9,7 @@ export function fetchStatusCard(id) {
|
|||
dispatch(fetchStatusCardRequest(id));
|
||||
|
||||
api(getState).get(`/api/v1/statuses/${id}/card`).then(response => {
|
||||
if (!response.data.url) {
|
||||
if (!response.data.url || !response.data.title || !response.data.description) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,12 @@ export function expandTimeline(timeline, id = null) {
|
|||
path = `${path}/${id}`
|
||||
}
|
||||
|
||||
api(getState).get(`/api/v1/timelines/${path}?max_id=${lastId}`).then(response => {
|
||||
api(getState).get(`/api/v1/timelines/${path}`, {
|
||||
params: {
|
||||
limit: 10,
|
||||
max_id: lastId
|
||||
}
|
||||
}).then(response => {
|
||||
dispatch(expandTimelineSuccess(timeline, response.data));
|
||||
}).catch(error => {
|
||||
dispatch(expandTimelineFail(timeline, error));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue