1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-15 23:28:31 +09:00
YuruToot/app/javascript/flavours/glitch/reducers/notification_policy.ts

26 lines
787 B
TypeScript
Raw Normal View History

import { createReducer, isAnyOf } from '@reduxjs/toolkit';
import {
fetchNotificationPolicy,
decreasePendingRequestsCount,
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(decreasePendingRequestsCount, (state, action) => {
if (state) {
state.summary.pending_requests_count -= action.payload;
}
})
.addMatcher(
isAnyOf(
fetchNotificationPolicy.fulfilled,
updateNotificationsPolicy.fulfilled,
),
(_state, action) => action.payload,
);
});