|
|
@ -14,11 +14,12 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';
|
|
|
|
|
|
|
|
|
|
|
|
export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
|
|
|
|
export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
|
|
|
|
|
|
|
|
|
|
|
|
export function refreshTimelineSuccess(timeline, statuses) {
|
|
|
|
export function refreshTimelineSuccess(timeline, statuses, skipLoading) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
type: TIMELINE_REFRESH_SUCCESS,
|
|
|
|
type: TIMELINE_REFRESH_SUCCESS,
|
|
|
|
timeline: timeline,
|
|
|
|
timeline,
|
|
|
|
statuses: statuses
|
|
|
|
statuses,
|
|
|
|
|
|
|
|
skipLoading
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -51,45 +52,49 @@ export function deleteFromTimelines(id) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function refreshTimelineRequest(timeline, id) {
|
|
|
|
export function refreshTimelineRequest(timeline, id, skipLoading) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
type: TIMELINE_REFRESH_REQUEST,
|
|
|
|
type: TIMELINE_REFRESH_REQUEST,
|
|
|
|
timeline,
|
|
|
|
timeline,
|
|
|
|
id
|
|
|
|
id,
|
|
|
|
|
|
|
|
skipLoading
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function refreshTimeline(timeline, id = null) {
|
|
|
|
export function refreshTimeline(timeline, id = null) {
|
|
|
|
return function (dispatch, getState) {
|
|
|
|
return function (dispatch, getState) {
|
|
|
|
dispatch(refreshTimelineRequest(timeline, id));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ids = getState().getIn(['timelines', timeline, 'items'], Immutable.List());
|
|
|
|
const ids = getState().getIn(['timelines', timeline, 'items'], Immutable.List());
|
|
|
|
const newestId = ids.size > 0 ? ids.first() : null;
|
|
|
|
const newestId = ids.size > 0 ? ids.first() : null;
|
|
|
|
|
|
|
|
|
|
|
|
let params = '';
|
|
|
|
let params = '';
|
|
|
|
let path = timeline;
|
|
|
|
let path = timeline;
|
|
|
|
|
|
|
|
let skipLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (newestId !== null && getState().getIn(['timelines', timeline, 'loaded'])) {
|
|
|
|
if (newestId !== null && getState().getIn(['timelines', timeline, 'loaded'])) {
|
|
|
|
params = `?since_id=${newestId}`;
|
|
|
|
params = `?since_id=${newestId}`;
|
|
|
|
|
|
|
|
skipLoading = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
if (id) {
|
|
|
|
path = `${path}/${id}`
|
|
|
|
path = `${path}/${id}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(refreshTimelineRequest(timeline, id, skipLoading));
|
|
|
|
|
|
|
|
|
|
|
|
api(getState).get(`/api/v1/timelines/${path}${params}`).then(function (response) {
|
|
|
|
api(getState).get(`/api/v1/timelines/${path}${params}`).then(function (response) {
|
|
|
|
dispatch(refreshTimelineSuccess(timeline, response.data));
|
|
|
|
dispatch(refreshTimelineSuccess(timeline, response.data, skipLoading));
|
|
|
|
}).catch(function (error) {
|
|
|
|
}).catch(function (error) {
|
|
|
|
dispatch(refreshTimelineFail(timeline, error));
|
|
|
|
dispatch(refreshTimelineFail(timeline, error, skipLoading));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function refreshTimelineFail(timeline, error) {
|
|
|
|
export function refreshTimelineFail(timeline, error, skipLoading) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
type: TIMELINE_REFRESH_FAIL,
|
|
|
|
type: TIMELINE_REFRESH_FAIL,
|
|
|
|
timeline,
|
|
|
|
timeline,
|
|
|
|
error
|
|
|
|
error,
|
|
|
|
|
|
|
|
skipLoading
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|