|
|
@ -1,10 +1,12 @@
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
TIMELINE_REFRESH_REQUEST,
|
|
|
|
TIMELINE_REFRESH_REQUEST,
|
|
|
|
TIMELINE_REFRESH_SUCCESS,
|
|
|
|
TIMELINE_REFRESH_SUCCESS,
|
|
|
|
|
|
|
|
TIMELINE_REFRESH_FAIL,
|
|
|
|
TIMELINE_UPDATE,
|
|
|
|
TIMELINE_UPDATE,
|
|
|
|
TIMELINE_DELETE,
|
|
|
|
TIMELINE_DELETE,
|
|
|
|
TIMELINE_EXPAND_SUCCESS,
|
|
|
|
TIMELINE_EXPAND_SUCCESS,
|
|
|
|
TIMELINE_EXPAND_REQUEST,
|
|
|
|
TIMELINE_EXPAND_REQUEST,
|
|
|
|
|
|
|
|
TIMELINE_EXPAND_FAIL,
|
|
|
|
TIMELINE_SCROLL_TOP
|
|
|
|
TIMELINE_SCROLL_TOP
|
|
|
|
} from '../actions/timelines';
|
|
|
|
} from '../actions/timelines';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
@ -16,8 +18,10 @@ import {
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
ACCOUNT_TIMELINE_FETCH_REQUEST,
|
|
|
|
ACCOUNT_TIMELINE_FETCH_REQUEST,
|
|
|
|
ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
|
|
|
ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
|
|
|
|
|
|
|
ACCOUNT_TIMELINE_FETCH_FAIL,
|
|
|
|
ACCOUNT_TIMELINE_EXPAND_REQUEST,
|
|
|
|
ACCOUNT_TIMELINE_EXPAND_REQUEST,
|
|
|
|
ACCOUNT_TIMELINE_EXPAND_SUCCESS,
|
|
|
|
ACCOUNT_TIMELINE_EXPAND_SUCCESS,
|
|
|
|
|
|
|
|
ACCOUNT_TIMELINE_EXPAND_FAIL,
|
|
|
|
ACCOUNT_BLOCK_SUCCESS
|
|
|
|
ACCOUNT_BLOCK_SUCCESS
|
|
|
|
} from '../actions/accounts';
|
|
|
|
} from '../actions/accounts';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
@ -232,31 +236,37 @@ const resetTimeline = (state, timeline, id) => {
|
|
|
|
|
|
|
|
|
|
|
|
export default function timelines(state = initialState, action) {
|
|
|
|
export default function timelines(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
switch(action.type) {
|
|
|
|
case TIMELINE_REFRESH_REQUEST:
|
|
|
|
case TIMELINE_REFRESH_REQUEST:
|
|
|
|
case TIMELINE_EXPAND_REQUEST:
|
|
|
|
case TIMELINE_EXPAND_REQUEST:
|
|
|
|
return resetTimeline(state, action.timeline, action.id);
|
|
|
|
return resetTimeline(state, action.timeline, action.id);
|
|
|
|
case TIMELINE_REFRESH_SUCCESS:
|
|
|
|
case TIMELINE_REFRESH_FAIL:
|
|
|
|
return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
|
|
|
|
case TIMELINE_EXPAND_FAIL:
|
|
|
|
case TIMELINE_EXPAND_SUCCESS:
|
|
|
|
return state.setIn([action.timeline, 'isLoading'], false);
|
|
|
|
return appendNormalizedTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
|
|
|
|
case TIMELINE_REFRESH_SUCCESS:
|
|
|
|
case TIMELINE_UPDATE:
|
|
|
|
return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
|
|
|
|
return updateTimeline(state, action.timeline, Immutable.fromJS(action.status), action.references);
|
|
|
|
case TIMELINE_EXPAND_SUCCESS:
|
|
|
|
case TIMELINE_DELETE:
|
|
|
|
return appendNormalizedTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
|
|
|
|
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
|
|
|
case TIMELINE_UPDATE:
|
|
|
|
case CONTEXT_FETCH_SUCCESS:
|
|
|
|
return updateTimeline(state, action.timeline, Immutable.fromJS(action.status), action.references);
|
|
|
|
return normalizeContext(state, action.id, Immutable.fromJS(action.ancestors), Immutable.fromJS(action.descendants));
|
|
|
|
case TIMELINE_DELETE:
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_REQUEST:
|
|
|
|
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_REQUEST:
|
|
|
|
case CONTEXT_FETCH_SUCCESS:
|
|
|
|
return state.updateIn(['accounts_timelines', action.id], Immutable.Map(), map => map.set('isLoading', true));
|
|
|
|
return normalizeContext(state, action.id, Immutable.fromJS(action.ancestors), Immutable.fromJS(action.descendants));
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_SUCCESS:
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_REQUEST:
|
|
|
|
return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_REQUEST:
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
|
|
|
|
return state.updateIn(['accounts_timelines', action.id], Immutable.Map(), map => map.set('isLoading', true));
|
|
|
|
return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_FAIL:
|
|
|
|
case ACCOUNT_BLOCK_SUCCESS:
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_FAIL:
|
|
|
|
return filterTimelines(state, action.relationship, action.statuses);
|
|
|
|
return state.updateIn(['accounts_timelines', action.id], Immutable.Map(), map => map.set('isLoading', false));
|
|
|
|
case TIMELINE_SCROLL_TOP:
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_SUCCESS:
|
|
|
|
return state.setIn([action.timeline, 'top'], action.top);
|
|
|
|
return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
|
|
|
|
default:
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
|
|
|
|
return state;
|
|
|
|
return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
|
|
|
|
|
|
|
|
case ACCOUNT_BLOCK_SUCCESS:
|
|
|
|
|
|
|
|
return filterTimelines(state, action.relationship, action.statuses);
|
|
|
|
|
|
|
|
case TIMELINE_SCROLL_TOP:
|
|
|
|
|
|
|
|
return state.setIn([action.timeline, 'top'], action.top);
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|