2025-01-03 17:12:08 +01:00
|
|
|
import { fromJS, Map as ImmutableMap } from 'immutable';
|
2023-05-23 17:15:17 +02:00
|
|
|
|
|
|
|
import {
|
2020-10-13 00:37:21 +02:00
|
|
|
NOTIFICATIONS_SET_BROWSER_SUPPORT,
|
|
|
|
NOTIFICATIONS_SET_BROWSER_PERMISSION,
|
2016-10-30 15:06:43 +01:00
|
|
|
} from '../actions/notifications';
|
2016-09-12 19:20:55 +02:00
|
|
|
|
2017-07-11 01:00:14 +02:00
|
|
|
const initialState = ImmutableMap({
|
2020-10-13 00:37:21 +02:00
|
|
|
browserSupport: false,
|
|
|
|
browserPermission: 'default',
|
2016-11-20 19:39:18 +01:00
|
|
|
});
|
|
|
|
|
2024-03-11 16:02:21 +01:00
|
|
|
export const notificationToMap = notification => ImmutableMap({
|
2016-11-20 19:39:18 +01:00
|
|
|
id: notification.id,
|
|
|
|
type: notification.type,
|
|
|
|
account: notification.account.id,
|
2018-08-26 17:53:26 +02:00
|
|
|
created_at: notification.created_at,
|
2017-05-21 00:31:47 +09:00
|
|
|
status: notification.status ? notification.status.id : null,
|
2022-06-27 09:30:15 +02:00
|
|
|
report: notification.report ? fromJS(notification.report) : null,
|
2024-03-20 16:37:21 +01:00
|
|
|
event: notification.event ? fromJS(notification.event) : null,
|
2024-04-25 19:26:05 +02:00
|
|
|
moderation_warning: notification.moderation_warning ? fromJS(notification.moderation_warning) : null,
|
2016-11-20 19:39:18 +01:00
|
|
|
});
|
|
|
|
|
2016-09-19 23:25:59 +02:00
|
|
|
export default function notifications(state = initialState, action) {
|
2016-09-12 19:20:55 +02:00
|
|
|
switch(action.type) {
|
2020-10-13 00:37:21 +02:00
|
|
|
case NOTIFICATIONS_SET_BROWSER_SUPPORT:
|
|
|
|
return state.set('browserSupport', action.value);
|
|
|
|
case NOTIFICATIONS_SET_BROWSER_PERMISSION:
|
|
|
|
return state.set('browserPermission', action.value);
|
2017-01-09 14:00:55 +01:00
|
|
|
default:
|
|
|
|
return state;
|
2016-09-12 19:20:55 +02:00
|
|
|
}
|
2022-12-18 10:51:37 -05:00
|
|
|
}
|