From e8ff4c8e56650bf061c63a7da3d84b742e618b6a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 30 Oct 2016 15:06:43 +0100 Subject: Refactoring redux state into different reducers --- .../javascripts/components/actions/timelines.jsx | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'app/assets/javascripts/components/actions/timelines.jsx') diff --git a/app/assets/javascripts/components/actions/timelines.jsx b/app/assets/javascripts/components/actions/timelines.jsx index 831065feb..01eee1712 100644 --- a/app/assets/javascripts/components/actions/timelines.jsx +++ b/app/assets/javascripts/components/actions/timelines.jsx @@ -21,17 +21,29 @@ export function refreshTimelineSuccess(timeline, statuses, replace) { }; export function updateTimeline(timeline, status) { - return { - type: TIMELINE_UPDATE, - timeline: timeline, - status: status + return (dispatch, getState) => { + const references = status.reblog ? getState().get('statuses').filter((item, itemId) => (itemId === status.reblog.id || item.get('reblog') === status.reblog.id)).map((_, itemId) => itemId) : []; + + dispatch({ + type: TIMELINE_UPDATE, + timeline, + status, + references + }); }; }; export function deleteFromTimelines(id) { - return { - type: TIMELINE_DELETE, - id: id + return (dispatch, getState) => { + const accountId = getState().getIn(['statuses', id, 'account']); + const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => [status.get('id'), status.get('account')]); + + dispatch({ + type: TIMELINE_DELETE, + id, + accountId, + references + }); }; }; -- cgit