diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-01-07 15:44:22 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-01-07 15:44:22 +0100 |
commit | 5c7add21761fc6b7d3c0af0819865242ce381960 (patch) | |
tree | c6928e1b99ec8218f40d0fac12214b1ec0dd21aa /app/assets/javascripts | |
parent | 7ddec6e7c3a8bdfcc69d28a723caca61cdb2a17c (diff) |
Fix #147 - Unreblogging will leave original status in feeds
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/components/actions/timelines.jsx | 4 | ||||
-rw-r--r-- | app/assets/javascripts/components/reducers/timelines.jsx | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/app/assets/javascripts/components/actions/timelines.jsx b/app/assets/javascripts/components/actions/timelines.jsx index 0e6f09190..8bb939d31 100644 --- a/app/assets/javascripts/components/actions/timelines.jsx +++ b/app/assets/javascripts/components/actions/timelines.jsx @@ -39,12 +39,14 @@ export function deleteFromTimelines(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')]); + const reblogOf = getState().getIn(['statuses', id, 'reblog'], null); dispatch({ type: TIMELINE_DELETE, id, accountId, - references + references, + reblogOf }); }; }; diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx index b73c83e0f..c5e3a253f 100644 --- a/app/assets/javascripts/components/reducers/timelines.jsx +++ b/app/assets/javascripts/components/reducers/timelines.jsx @@ -145,7 +145,12 @@ const updateTimeline = (state, timeline, status, references) => { return state; }; -const deleteStatus = (state, id, accountId, references) => { +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)); + } + // Remove references from timelines ['home', 'mentions', 'public', 'tag'].forEach(function (timeline) { state = state.updateIn([timeline, 'items'], list => list.filterNot(item => item === id)); @@ -220,7 +225,7 @@ export default function timelines(state = initialState, action) { 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); + 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_SUCCESS: |