2016-09-18 16:18:46 +00:00
|
|
|
import {
|
2016-12-03 20:04:57 +00:00
|
|
|
TIMELINE_REFRESH_REQUEST,
|
2016-09-20 21:18:00 +00:00
|
|
|
TIMELINE_REFRESH_SUCCESS,
|
2017-01-24 12:04:12 +00:00
|
|
|
TIMELINE_REFRESH_FAIL,
|
2016-09-18 16:18:46 +00:00
|
|
|
TIMELINE_UPDATE,
|
2016-09-21 23:08:35 +00:00
|
|
|
TIMELINE_DELETE,
|
2016-12-03 20:04:57 +00:00
|
|
|
TIMELINE_EXPAND_SUCCESS,
|
2017-01-24 03:12:10 +00:00
|
|
|
TIMELINE_EXPAND_REQUEST,
|
2017-01-24 12:04:12 +00:00
|
|
|
TIMELINE_EXPAND_FAIL,
|
2017-04-02 19:44:06 +00:00
|
|
|
TIMELINE_SCROLL_TOP,
|
|
|
|
TIMELINE_CONNECT,
|
2017-05-20 15:31:47 +00:00
|
|
|
TIMELINE_DISCONNECT,
|
2016-10-30 14:06:43 +00:00
|
|
|
} from '../actions/timelines';
|
2016-09-18 16:18:46 +00:00
|
|
|
import {
|
|
|
|
REBLOG_SUCCESS,
|
2016-10-02 13:14:26 +00:00
|
|
|
UNREBLOG_SUCCESS,
|
|
|
|
FAVOURITE_SUCCESS,
|
2017-05-20 15:31:47 +00:00
|
|
|
UNFAVOURITE_SUCCESS,
|
2016-10-30 14:06:43 +00:00
|
|
|
} from '../actions/interactions';
|
2016-09-18 16:18:46 +00:00
|
|
|
import {
|
2017-01-24 03:12:10 +00:00
|
|
|
ACCOUNT_TIMELINE_FETCH_REQUEST,
|
2016-09-22 18:58:35 +00:00
|
|
|
ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
2017-01-24 12:04:12 +00:00
|
|
|
ACCOUNT_TIMELINE_FETCH_FAIL,
|
2017-01-24 03:12:10 +00:00
|
|
|
ACCOUNT_TIMELINE_EXPAND_REQUEST,
|
2016-11-23 21:57:57 +00:00
|
|
|
ACCOUNT_TIMELINE_EXPAND_SUCCESS,
|
2017-01-24 12:04:12 +00:00
|
|
|
ACCOUNT_TIMELINE_EXPAND_FAIL,
|
2017-05-19 23:28:25 +00:00
|
|
|
ACCOUNT_MEDIA_TIMELINE_FETCH_REQUEST,
|
|
|
|
ACCOUNT_MEDIA_TIMELINE_FETCH_SUCCESS,
|
|
|
|
ACCOUNT_MEDIA_TIMELINE_FETCH_FAIL,
|
|
|
|
ACCOUNT_MEDIA_TIMELINE_EXPAND_REQUEST,
|
|
|
|
ACCOUNT_MEDIA_TIMELINE_EXPAND_SUCCESS,
|
|
|
|
ACCOUNT_MEDIA_TIMELINE_EXPAND_FAIL,
|
2017-03-02 17:49:32 +00:00
|
|
|
ACCOUNT_BLOCK_SUCCESS,
|
2017-05-20 15:31:47 +00:00
|
|
|
ACCOUNT_MUTE_SUCCESS,
|
2016-10-30 14:06:43 +00:00
|
|
|
} from '../actions/accounts';
|
2016-09-29 22:00:45 +00:00
|
|
|
import {
|
2017-05-20 15:31:47 +00:00
|
|
|
CONTEXT_FETCH_SUCCESS,
|
2016-10-30 14:06:43 +00:00
|
|
|
} from '../actions/statuses';
|
|
|
|
import Immutable from 'immutable';
|
2016-08-24 15:56:44 +00:00
|
|
|
|
2016-09-04 12:04:26 +00:00
|
|
|
const initialState = Immutable.Map({
|
2016-12-03 20:04:57 +00:00
|
|
|
home: Immutable.Map({
|
2017-02-19 19:25:54 +00:00
|
|
|
path: () => '/api/v1/timelines/home',
|
|
|
|
next: null,
|
2017-01-24 03:12:10 +00:00
|
|
|
isLoading: false,
|
2017-04-02 19:44:06 +00:00
|
|
|
online: false,
|
2016-12-03 20:04:57 +00:00
|
|
|
loaded: false,
|
|
|
|
top: true,
|
2017-02-20 23:10:49 +00:00
|
|
|
unread: 0,
|
2017-05-20 15:31:47 +00:00
|
|
|
items: Immutable.List(),
|
2016-12-03 20:04:57 +00:00
|
|
|
}),
|
|
|
|
|
2017-02-19 19:25:54 +00:00
|
|
|
public: Immutable.Map({
|
|
|
|
path: () => '/api/v1/timelines/public',
|
|
|
|
next: null,
|
2017-01-24 03:12:10 +00:00
|
|
|
isLoading: false,
|
2017-04-02 19:44:06 +00:00
|
|
|
online: false,
|
2016-12-03 20:04:57 +00:00
|
|
|
loaded: false,
|
|
|
|
top: true,
|
2017-02-20 23:10:49 +00:00
|
|
|
unread: 0,
|
2017-05-20 15:31:47 +00:00
|
|
|
items: Immutable.List(),
|
2016-12-03 20:04:57 +00:00
|
|
|
}),
|
|
|
|
|
2017-02-19 19:25:54 +00:00
|
|
|
community: Immutable.Map({
|
|
|
|
path: () => '/api/v1/timelines/public',
|
|
|
|
next: null,
|
|
|
|
params: { local: true },
|
2017-01-24 03:12:10 +00:00
|
|
|
isLoading: false,
|
2017-04-02 19:44:06 +00:00
|
|
|
online: false,
|
2016-12-03 20:04:57 +00:00
|
|
|
loaded: false,
|
|
|
|
top: true,
|
2017-02-20 23:10:49 +00:00
|
|
|
unread: 0,
|
2017-05-20 15:31:47 +00:00
|
|
|
items: Immutable.List(),
|
2016-12-03 20:04:57 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
tag: Immutable.Map({
|
2017-02-19 19:25:54 +00:00
|
|
|
path: (id) => `/api/v1/timelines/tag/${id}`,
|
|
|
|
next: null,
|
2017-01-24 03:12:10 +00:00
|
|
|
isLoading: false,
|
2016-12-03 20:04:57 +00:00
|
|
|
id: null,
|
|
|
|
loaded: false,
|
|
|
|
top: true,
|
2017-02-20 23:10:49 +00:00
|
|
|
unread: 0,
|
2017-05-20 15:31:47 +00:00
|
|
|
items: Immutable.List(),
|
2016-12-03 20:04:57 +00:00
|
|
|
}),
|
|
|
|
|
2016-09-18 16:18:46 +00:00
|
|
|
accounts_timelines: Immutable.Map(),
|
2017-05-19 23:28:25 +00:00
|
|
|
accounts_media_timelines: Immutable.Map(),
|
2016-09-15 22:21:51 +00:00
|
|
|
ancestors: Immutable.Map(),
|
2017-05-20 15:31:47 +00:00
|
|
|
descendants: Immutable.Map(),
|
2016-09-04 12:04:26 +00:00
|
|
|
});
|
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
const normalizeStatus = (state, status) => {
|
|
|
|
const replyToId = status.get('in_reply_to_id');
|
|
|
|
const id = status.get('id');
|
2016-09-04 12:04:26 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
if (replyToId) {
|
|
|
|
if (!state.getIn(['descendants', replyToId], Immutable.List()).includes(id)) {
|
|
|
|
state = state.updateIn(['descendants', replyToId], Immutable.List(), set => set.push(id));
|
|
|
|
}
|
2016-09-18 10:51:09 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
if (!state.getIn(['ancestors', id], Immutable.List()).includes(replyToId)) {
|
|
|
|
state = state.updateIn(['ancestors', id], Immutable.List(), set => set.push(replyToId));
|
2016-09-18 10:51:09 +00:00
|
|
|
}
|
2016-10-30 14:06:43 +00:00
|
|
|
}
|
2016-09-18 10:51:09 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
return state;
|
2016-09-04 12:04:26 +00:00
|
|
|
};
|
|
|
|
|
2017-02-19 19:25:54 +00:00
|
|
|
const normalizeTimeline = (state, timeline, statuses, next) => {
|
2016-12-03 20:04:57 +00:00
|
|
|
let ids = Immutable.List();
|
|
|
|
const loaded = state.getIn([timeline, 'loaded']);
|
2016-10-17 23:48:46 +00:00
|
|
|
|
2016-09-04 12:04:26 +00:00
|
|
|
statuses.forEach((status, i) => {
|
2016-09-19 21:25:59 +00:00
|
|
|
state = normalizeStatus(state, status);
|
2016-10-17 23:48:46 +00:00
|
|
|
ids = ids.set(i, status.get('id'));
|
2016-09-01 11:21:48 +00:00
|
|
|
});
|
2016-09-04 12:04:26 +00:00
|
|
|
|
2016-12-03 20:04:57 +00:00
|
|
|
state = state.setIn([timeline, 'loaded'], true);
|
2017-01-24 03:12:10 +00:00
|
|
|
state = state.setIn([timeline, 'isLoading'], false);
|
2017-02-19 20:37:04 +00:00
|
|
|
|
|
|
|
if (state.getIn([timeline, 'next']) === null) {
|
|
|
|
state = state.setIn([timeline, 'next'], next);
|
|
|
|
}
|
2016-12-03 20:04:57 +00:00
|
|
|
|
2017-05-03 00:04:16 +00:00
|
|
|
return state.updateIn([timeline, 'items'], Immutable.List(), list => (loaded ? ids.concat(list) : ids));
|
2016-09-04 12:04:26 +00:00
|
|
|
};
|
|
|
|
|
2017-02-19 19:25:54 +00:00
|
|
|
const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
2016-10-30 14:06:43 +00:00
|
|
|
let moreIds = Immutable.List();
|
2016-09-21 23:08:35 +00:00
|
|
|
|
|
|
|
statuses.forEach((status, i) => {
|
|
|
|
state = normalizeStatus(state, status);
|
|
|
|
moreIds = moreIds.set(i, status.get('id'));
|
|
|
|
});
|
|
|
|
|
2017-01-24 03:12:10 +00:00
|
|
|
state = state.setIn([timeline, 'isLoading'], false);
|
2017-02-19 19:25:54 +00:00
|
|
|
state = state.setIn([timeline, 'next'], next);
|
2017-01-24 03:12:10 +00:00
|
|
|
|
2017-05-03 00:04:16 +00:00
|
|
|
return state.updateIn([timeline, 'items'], Immutable.List(), list => list.concat(moreIds));
|
2016-09-21 23:08:35 +00:00
|
|
|
};
|
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
const normalizeAccountTimeline = (state, accountId, statuses, replace = false) => {
|
|
|
|
let ids = Immutable.List();
|
2016-10-07 14:00:11 +00:00
|
|
|
|
2016-09-18 16:18:46 +00:00
|
|
|
statuses.forEach((status, i) => {
|
2016-09-19 21:25:59 +00:00
|
|
|
state = normalizeStatus(state, status);
|
2016-10-18 21:06:28 +00:00
|
|
|
ids = ids.set(i, status.get('id'));
|
2016-09-18 16:18:46 +00:00
|
|
|
});
|
|
|
|
|
2017-01-24 03:12:10 +00:00
|
|
|
return state.updateIn(['accounts_timelines', accountId], Immutable.Map(), map => map
|
|
|
|
.set('isLoading', false)
|
|
|
|
.set('loaded', true)
|
2017-04-18 11:10:49 +00:00
|
|
|
.set('next', true)
|
2017-05-03 00:04:16 +00:00
|
|
|
.update('items', Immutable.List(), list => (replace ? ids : ids.concat(list))));
|
2016-09-18 16:18:46 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 23:28:25 +00:00
|
|
|
const normalizeAccountMediaTimeline = (state, accountId, statuses, next) => {
|
|
|
|
let ids = Immutable.List();
|
|
|
|
|
|
|
|
statuses.forEach((status, i) => {
|
|
|
|
state = normalizeStatus(state, status);
|
|
|
|
ids = ids.set(i, status.get('id'));
|
|
|
|
});
|
|
|
|
|
|
|
|
return state.updateIn(['accounts_media_timelines', accountId], Immutable.Map(), map => map
|
|
|
|
.set('isLoading', false)
|
|
|
|
.set('next', next)
|
|
|
|
.update('items', Immutable.List(), list => ids.concat(list)));
|
|
|
|
};
|
|
|
|
|
2017-04-18 11:10:49 +00:00
|
|
|
const appendNormalizedAccountTimeline = (state, accountId, statuses, next) => {
|
2016-10-07 14:00:11 +00:00
|
|
|
let moreIds = Immutable.List([]);
|
2016-09-22 18:58:35 +00:00
|
|
|
|
|
|
|
statuses.forEach((status, i) => {
|
|
|
|
state = normalizeStatus(state, status);
|
|
|
|
moreIds = moreIds.set(i, status.get('id'));
|
|
|
|
});
|
|
|
|
|
2017-01-24 03:12:10 +00:00
|
|
|
return state.updateIn(['accounts_timelines', accountId], Immutable.Map(), map => map
|
|
|
|
.set('isLoading', false)
|
2017-04-18 11:10:49 +00:00
|
|
|
.set('next', next)
|
2017-05-03 00:04:16 +00:00
|
|
|
.update('items', list => list.concat(moreIds)));
|
2016-09-22 18:58:35 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 23:28:25 +00:00
|
|
|
const appendNormalizedAccountMediaTimeline = (state, accountId, statuses, next) => {
|
|
|
|
let moreIds = Immutable.List([]);
|
|
|
|
|
|
|
|
statuses.forEach((status, i) => {
|
|
|
|
state = normalizeStatus(state, status);
|
|
|
|
moreIds = moreIds.set(i, status.get('id'));
|
|
|
|
});
|
|
|
|
|
|
|
|
return state.updateIn(['accounts_media_timelines', accountId], Immutable.Map(), map => map
|
|
|
|
.set('isLoading', false)
|
|
|
|
.set('next', next)
|
|
|
|
.update('items', list => list.concat(moreIds)));
|
|
|
|
};
|
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
const updateTimeline = (state, timeline, status, references) => {
|
2016-12-03 20:04:57 +00:00
|
|
|
const top = state.getIn([timeline, 'top']);
|
|
|
|
|
2016-09-19 21:25:59 +00:00
|
|
|
state = normalizeStatus(state, status);
|
2016-10-16 23:34:16 +00:00
|
|
|
|
2017-02-20 23:10:49 +00:00
|
|
|
if (!top) {
|
|
|
|
state = state.updateIn([timeline, 'unread'], unread => unread + 1);
|
|
|
|
}
|
|
|
|
|
2016-12-03 20:04:57 +00:00
|
|
|
state = state.updateIn([timeline, 'items'], Immutable.List(), list => {
|
|
|
|
if (top && list.size > 40) {
|
|
|
|
list = list.take(20);
|
|
|
|
}
|
|
|
|
|
2016-11-03 10:06:55 +00:00
|
|
|
if (list.includes(status.get('id'))) {
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2016-10-16 23:34:16 +00:00
|
|
|
const reblogOfId = status.getIn(['reblog', 'id'], null);
|
|
|
|
|
|
|
|
if (reblogOfId !== null) {
|
2016-10-30 14:06:43 +00:00
|
|
|
list = list.filterNot(itemId => references.includes(itemId));
|
2016-10-16 23:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list.unshift(status.get('id'));
|
|
|
|
});
|
|
|
|
|
2016-09-04 12:04:26 +00:00
|
|
|
return state;
|
2016-09-01 11:21:48 +00:00
|
|
|
};
|
|
|
|
|
2017-01-07 14:44:22 +00:00
|
|
|
const deleteStatus = (state, id, accountId, references, reblogOf) => {
|
|
|
|
if (reblogOf) {
|
|
|
|
// If we are deleting a reblog, just replace reblog with its original
|
|
|
|
return state.updateIn(['home', 'items'], list => list.map(item => item === id ? reblogOf : item));
|
|
|
|
}
|
|
|
|
|
2016-09-29 22:00:45 +00:00
|
|
|
// Remove references from timelines
|
2017-02-19 19:25:54 +00:00
|
|
|
['home', 'public', 'community', 'tag'].forEach(function (timeline) {
|
2016-12-03 20:04:57 +00:00
|
|
|
state = state.updateIn([timeline, 'items'], list => list.filterNot(item => item === id));
|
2016-09-04 23:59:46 +00:00
|
|
|
});
|
|
|
|
|
2016-09-29 22:00:45 +00:00
|
|
|
// Remove references from account timelines
|
2017-01-24 03:12:10 +00:00
|
|
|
state = state.updateIn(['accounts_timelines', accountId, 'items'], Immutable.List([]), list => list.filterNot(item => item === id));
|
2017-05-19 23:28:25 +00:00
|
|
|
state = state.updateIn(['accounts_media_timelines', accountId, 'items'], Immutable.List([]), list => list.filterNot(item => item === id));
|
2016-09-29 22:00:45 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
// Remove references from context
|
|
|
|
state.getIn(['descendants', id], Immutable.List()).forEach(descendantId => {
|
|
|
|
state = state.updateIn(['ancestors', descendantId], Immutable.List(), list => list.filterNot(itemId => itemId === id));
|
2016-09-29 22:00:45 +00:00
|
|
|
});
|
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
state.getIn(['ancestors', id], Immutable.List()).forEach(ancestorId => {
|
|
|
|
state = state.updateIn(['descendants', ancestorId], Immutable.List(), list => list.filterNot(itemId => itemId === id));
|
|
|
|
});
|
2016-10-15 11:48:38 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
state = state.deleteIn(['descendants', id]).deleteIn(['ancestors', id]);
|
2016-09-23 18:23:26 +00:00
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
// Remove reblogs of deleted status
|
|
|
|
references.forEach(ref => {
|
|
|
|
state = deleteStatus(state, ref[0], ref[1], []);
|
2016-10-28 18:05:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return state;
|
|
|
|
};
|
|
|
|
|
2016-11-23 21:57:57 +00:00
|
|
|
const filterTimelines = (state, relationship, statuses) => {
|
|
|
|
let references;
|
|
|
|
|
|
|
|
statuses.forEach(status => {
|
|
|
|
if (status.get('account') !== relationship.id) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
references = statuses.filter(item => item.get('reblog') === status.get('id')).map(item => [item.get('id'), item.get('account')]);
|
|
|
|
state = deleteStatus(state, status.get('id'), status.get('account'), references);
|
|
|
|
});
|
|
|
|
|
|
|
|
return state;
|
|
|
|
};
|
|
|
|
|
2016-10-30 14:06:43 +00:00
|
|
|
const normalizeContext = (state, id, ancestors, descendants) => {
|
|
|
|
const ancestorsIds = ancestors.map(ancestor => ancestor.get('id'));
|
|
|
|
const descendantsIds = descendants.map(descendant => descendant.get('id'));
|
2016-09-15 22:21:51 +00:00
|
|
|
|
|
|
|
return state.withMutations(map => {
|
2016-10-30 14:06:43 +00:00
|
|
|
map.setIn(['ancestors', id], ancestorsIds);
|
|
|
|
map.setIn(['descendants', id], descendantsIds);
|
2016-09-15 22:21:51 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-12-03 20:04:57 +00:00
|
|
|
const resetTimeline = (state, timeline, id) => {
|
2017-02-19 19:25:54 +00:00
|
|
|
if (timeline === 'tag' && typeof id !== 'undefined' && state.getIn([timeline, 'id']) !== id) {
|
2016-12-03 20:04:57 +00:00
|
|
|
state = state.update(timeline, map => map
|
|
|
|
.set('id', id)
|
2017-01-24 03:12:10 +00:00
|
|
|
.set('isLoading', true)
|
2016-12-03 20:04:57 +00:00
|
|
|
.set('loaded', false)
|
2017-02-19 20:37:04 +00:00
|
|
|
.set('next', null)
|
2017-02-22 14:43:07 +00:00
|
|
|
.set('top', true)
|
2016-12-03 20:04:57 +00:00
|
|
|
.update('items', list => list.clear()));
|
2017-01-24 03:12:10 +00:00
|
|
|
} else {
|
|
|
|
state = state.setIn([timeline, 'isLoading'], true);
|
2016-12-03 20:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
};
|
|
|
|
|
2017-02-20 23:10:49 +00:00
|
|
|
const updateTop = (state, timeline, top) => {
|
|
|
|
if (top) {
|
|
|
|
state = state.setIn([timeline, 'unread'], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state.setIn([timeline, 'top'], top);
|
|
|
|
};
|
|
|
|
|
2016-08-31 14:15:12 +00:00
|
|
|
export default function timelines(state = initialState, action) {
|
2016-08-24 15:56:44 +00:00
|
|
|
switch(action.type) {
|
2017-01-24 12:04:12 +00:00
|
|
|
case TIMELINE_REFRESH_REQUEST:
|
|
|
|
case TIMELINE_EXPAND_REQUEST:
|
|
|
|
return resetTimeline(state, action.timeline, action.id);
|
|
|
|
case TIMELINE_REFRESH_FAIL:
|
|
|
|
case TIMELINE_EXPAND_FAIL:
|
|
|
|
return state.setIn([action.timeline, 'isLoading'], false);
|
|
|
|
case TIMELINE_REFRESH_SUCCESS:
|
2017-02-19 19:25:54 +00:00
|
|
|
return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses), action.next);
|
2017-01-24 12:04:12 +00:00
|
|
|
case TIMELINE_EXPAND_SUCCESS:
|
2017-02-19 19:25:54 +00:00
|
|
|
return appendNormalizedTimeline(state, action.timeline, Immutable.fromJS(action.statuses), action.next);
|
2017-01-24 12:04:12 +00:00
|
|
|
case TIMELINE_UPDATE:
|
|
|
|
return updateTimeline(state, action.timeline, Immutable.fromJS(action.status), action.references);
|
|
|
|
case TIMELINE_DELETE:
|
|
|
|
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
|
|
|
case CONTEXT_FETCH_SUCCESS:
|
|
|
|
return normalizeContext(state, action.id, Immutable.fromJS(action.ancestors), Immutable.fromJS(action.descendants));
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_REQUEST:
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_REQUEST:
|
|
|
|
return state.updateIn(['accounts_timelines', action.id], Immutable.Map(), map => map.set('isLoading', true));
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_FAIL:
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_FAIL:
|
|
|
|
return state.updateIn(['accounts_timelines', action.id], Immutable.Map(), map => map.set('isLoading', false));
|
|
|
|
case ACCOUNT_TIMELINE_FETCH_SUCCESS:
|
|
|
|
return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
|
|
|
|
case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
|
2017-04-18 11:10:49 +00:00
|
|
|
return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.next);
|
2017-05-19 23:28:25 +00:00
|
|
|
case ACCOUNT_MEDIA_TIMELINE_FETCH_REQUEST:
|
|
|
|
case ACCOUNT_MEDIA_TIMELINE_EXPAND_REQUEST:
|
|
|
|
return state.updateIn(['accounts_media_timelines', action.id], Immutable.Map(), map => map.set('isLoading', true));
|
|
|
|
case ACCOUNT_MEDIA_TIMELINE_FETCH_FAIL:
|
|
|
|
case ACCOUNT_MEDIA_TIMELINE_EXPAND_FAIL:
|
|
|
|
return state.updateIn(['accounts_media_timelines', action.id], Immutable.Map(), map => map.set('isLoading', false));
|
|
|
|
case ACCOUNT_MEDIA_TIMELINE_FETCH_SUCCESS:
|
|
|
|
return normalizeAccountMediaTimeline(state, action.id, Immutable.fromJS(action.statuses), action.next);
|
|
|
|
case ACCOUNT_MEDIA_TIMELINE_EXPAND_SUCCESS:
|
|
|
|
return appendNormalizedAccountMediaTimeline(state, action.id, Immutable.fromJS(action.statuses), action.next);
|
2017-01-24 12:04:12 +00:00
|
|
|
case ACCOUNT_BLOCK_SUCCESS:
|
2017-03-02 17:49:32 +00:00
|
|
|
case ACCOUNT_MUTE_SUCCESS:
|
2017-01-24 12:04:12 +00:00
|
|
|
return filterTimelines(state, action.relationship, action.statuses);
|
|
|
|
case TIMELINE_SCROLL_TOP:
|
2017-02-20 23:10:49 +00:00
|
|
|
return updateTop(state, action.timeline, action.top);
|
2017-04-02 19:44:06 +00:00
|
|
|
case TIMELINE_CONNECT:
|
|
|
|
return state.setIn([action.timeline, 'online'], true);
|
|
|
|
case TIMELINE_DISCONNECT:
|
|
|
|
return state.setIn([action.timeline, 'online'], false);
|
2017-01-24 12:04:12 +00:00
|
|
|
default:
|
|
|
|
return state;
|
2016-08-24 15:56:44 +00:00
|
|
|
}
|
2016-09-12 17:20:55 +00:00
|
|
|
};
|