diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-30 15:06:43 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-30 15:06:43 +0100 |
commit | e8ff4c8e56650bf061c63a7da3d84b742e618b6a (patch) | |
tree | cb9aa48393bc6108655db7490434ae29d3145ee5 /app/assets/javascripts/components/actions/timelines.jsx | |
parent | 7060bdf04bde59aab9addce95f00d6e1075a62ba (diff) |
Refactoring redux state into different reducers
Diffstat (limited to 'app/assets/javascripts/components/actions/timelines.jsx')
-rw-r--r-- | app/assets/javascripts/components/actions/timelines.jsx | 26 |
1 files changed, 19 insertions, 7 deletions
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 + }); }; }; |