2024-06-18 22:23:30 +09:00
|
|
|
import { createReducer, isAnyOf } from '@reduxjs/toolkit';
|
|
|
|
|
|
|
|
import {
|
|
|
|
fetchNotificationPolicy,
|
2024-09-25 00:03:38 +09:00
|
|
|
decreasePendingRequestsCount,
|
2024-06-18 22:23:30 +09:00
|
|
|
updateNotificationsPolicy,
|
|
|
|
} from 'flavours/glitch/actions/notification_policies';
|
|
|
|
import type { NotificationPolicy } from 'flavours/glitch/models/notification_policy';
|
|
|
|
|
|
|
|
export const notificationPolicyReducer =
|
|
|
|
createReducer<NotificationPolicy | null>(null, (builder) => {
|
2024-07-26 18:36:54 +09:00
|
|
|
builder
|
2024-09-25 00:03:38 +09:00
|
|
|
.addCase(decreasePendingRequestsCount, (state, action) => {
|
2024-07-26 18:36:54 +09:00
|
|
|
if (state) {
|
2024-09-25 00:03:38 +09:00
|
|
|
state.summary.pending_requests_count -= action.payload;
|
2024-07-26 18:36:54 +09:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.addMatcher(
|
|
|
|
isAnyOf(
|
|
|
|
fetchNotificationPolicy.fulfilled,
|
|
|
|
updateNotificationsPolicy.fulfilled,
|
|
|
|
),
|
|
|
|
(_state, action) => action.payload,
|
|
|
|
);
|
2024-06-18 22:23:30 +09:00
|
|
|
});
|