1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-14 22:59:46 +09:00
YuruToot/app/javascript/flavours/glitch/reducers/notification_policy.ts
David Roetzel 0e18e1ba31 [Glitch] Decrease count of filtered notifications when notification requests are accepted or dismissed
Port dfd43869c9 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2024-07-27 15:16:15 +02:00

27 lines
855 B
TypeScript

import { createReducer, isAnyOf } from '@reduxjs/toolkit';
import {
fetchNotificationPolicy,
decreasePendingNotificationsCount,
updateNotificationsPolicy,
} from 'flavours/glitch/actions/notification_policies';
import type { NotificationPolicy } from 'flavours/glitch/models/notification_policy';
export const notificationPolicyReducer =
createReducer<NotificationPolicy | null>(null, (builder) => {
builder
.addCase(decreasePendingNotificationsCount, (state, action) => {
if (state) {
state.summary.pending_notifications_count -= action.payload;
state.summary.pending_requests_count -= 1;
}
})
.addMatcher(
isAnyOf(
fetchNotificationPolicy.fulfilled,
updateNotificationsPolicy.fulfilled,
),
(_state, action) => action.payload,
);
});