[Glitch] Change account domain block to clear out notifications and follows
Port 4eeff26533
to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
committed by
Thibaut Girka
parent
bca3825c17
commit
31fc3be0a4
@@ -21,6 +21,7 @@ import {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from 'flavours/glitch/actions/accounts';
|
||||
import { DOMAIN_BLOCK_SUCCESS } from 'flavours/glitch/actions/domain_blocks';
|
||||
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from 'flavours/glitch/actions/timelines';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import compareId from 'flavours/glitch/util/compare_id';
|
||||
@@ -110,8 +111,8 @@ const expandNormalizedNotifications = (state, notifications, next, usePendingIte
|
||||
});
|
||||
};
|
||||
|
||||
const filterNotifications = (state, relationship) => {
|
||||
const helper = list => list.filterNot(item => item !== null && item.get('account') === relationship.id);
|
||||
const filterNotifications = (state, accountIds) => {
|
||||
const helper = list => list.filterNot(item => item !== null && accountIds.includes(item.get('account')));
|
||||
return state.update('items', helper).update('pendingItems', helper);
|
||||
};
|
||||
|
||||
@@ -217,9 +218,11 @@ export default function notifications(state = initialState, action) {
|
||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||
return expandNormalizedNotifications(state, action.notifications, action.next, action.usePendingItems);
|
||||
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('pendingItems', ImmutableList()).set('hasMore', false);
|
||||
case TIMELINE_DELETE:
|
||||
|
Reference in New Issue
Block a user