Change account domain block to clear out notifications and follows (#11393)

This commit is contained in:
Eugen Rochko
2019-07-25 04:17:35 +02:00
parent 4e4f73b231
commit ed27803822
7 changed files with 51 additions and 35 deletions

View File

@ -11,6 +11,7 @@ import {
ACCOUNT_BLOCK_SUCCESS,
ACCOUNT_MUTE_SUCCESS,
} from '../actions/accounts';
import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import compareId from '../compare_id';
@ -77,8 +78,8 @@ const expandNormalizedNotifications = (state, notifications, next) => {
});
};
const filterNotifications = (state, relationship) => {
return state.update('items', list => list.filterNot(item => item !== null && item.get('account') === relationship.id));
const filterNotifications = (state, accountIds) => {
return state.update('items', list => list.filterNot(item => item !== null && accountIds.includes(item.get('account'))));
};
const updateTop = (state, top) => {
@ -108,9 +109,11 @@ export default function notifications(state = initialState, action) {
case NOTIFICATIONS_EXPAND_SUCCESS:
return expandNormalizedNotifications(state, action.notifications, action.next);
case ACCOUNT_BLOCK_SUCCESS:
return filterNotifications(state, action.relationship);
return filterNotifications(state, [action.relationship.id]);
case ACCOUNT_MUTE_SUCCESS:
return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state;
return action.relationship.muting_notifications ? filterNotifications(state, [action.relationship.id]) : state;
case DOMAIN_BLOCK_SUCCESS:
return filterNotifications(state, action.accounts);
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE: