Browse Source

Fix #147 - Unreblogging will leave original status in feeds

closed-social-v3
Eugen Rochko 7 years ago
parent
commit
5c7add2176
3 changed files with 16 additions and 4 deletions
  1. +3
    -1
      app/assets/javascripts/components/actions/timelines.jsx
  2. +7
    -2
      app/assets/javascripts/components/reducers/timelines.jsx
  3. +6
    -1
      app/services/remove_status_service.rb

+ 3
- 1
app/assets/javascripts/components/actions/timelines.jsx View File

@ -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
});
};
};

+ 7
- 2
app/assets/javascripts/components/reducers/timelines.jsx View File

@ -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:

+ 6
- 1
app/services/remove_status_service.rb View File

@ -53,7 +53,12 @@ class RemoveStatusService < BaseService
end
def unpush(type, receiver, status)
redis.zremrangebyscore(FeedManager.instance.key(type, receiver.id), status.id, status.id)
if status.reblog?
redis.zadd(FeedManager.instance.key(type, receiver.id), status.reblog_of_id, status.reblog_of_id)
else
redis.zremrangebyscore(FeedManager.instance.key(type, receiver.id), status.id, status.id)
end
FeedManager.instance.broadcast(receiver.id, type: 'delete', id: status.id)
end

Loading…
Cancel
Save