Skip to content

Commit

Permalink
Fix mutes and blocks not immediately cleaning up notification request…
Browse files Browse the repository at this point in the history
…s in Web UI (mastodon#31316)
  • Loading branch information
ClearlyClaire authored Aug 6, 2024
1 parent 07ccecf commit 9aeebda
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/javascript/mastodon/reducers/notification_requests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';

import { blockAccountSuccess, muteAccountSuccess } from 'mastodon/actions/accounts';
import {
NOTIFICATION_REQUESTS_EXPAND_REQUEST,
NOTIFICATION_REQUESTS_EXPAND_SUCCESS,
Expand Down Expand Up @@ -51,6 +52,14 @@ const removeRequest = (state, id) => {
return state.update('items', list => list.filterNot(item => item.get('id') === id));
};

const removeRequestByAccount = (state, account_id) => {
if (state.getIn(['current', 'item', 'account']) === account_id) {
state = state.setIn(['current', 'removed'], true);
}

return state.update('items', list => list.filterNot(item => item.get('account') === account_id));
};

export const notificationRequestsReducer = (state = initialState, action) => {
switch(action.type) {
case NOTIFICATION_REQUESTS_FETCH_SUCCESS:
Expand All @@ -74,6 +83,10 @@ export const notificationRequestsReducer = (state = initialState, action) => {
case NOTIFICATION_REQUEST_ACCEPT_REQUEST:
case NOTIFICATION_REQUEST_DISMISS_REQUEST:
return removeRequest(state, action.id);
case blockAccountSuccess.type:
return removeRequestByAccount(state, action.payload.relationship.id);
case muteAccountSuccess.type:
return action.payload.relationship.muting_notifications ? removeRequestByAccount(state, action.payload.relationship.id) : state;
case NOTIFICATION_REQUEST_FETCH_REQUEST:
return state.set('current', initialState.get('current').set('isLoading', true));
case NOTIFICATION_REQUEST_FETCH_SUCCESS:
Expand Down

0 comments on commit 9aeebda

Please sign in to comment.