mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 00:38:27 +00:00
[Glitch] Convert notification requests actions and reducers to Typescript
Port c0eda832f3 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -55,11 +55,11 @@ const initialState = ImmutableMap({
|
||||
markNewForDelete: false,
|
||||
});
|
||||
|
||||
export const notificationToMap = (notification, markForDelete = false) => ImmutableMap({
|
||||
export const notificationToMap = (notification) => ImmutableMap({
|
||||
id: notification.id,
|
||||
type: notification.type,
|
||||
account: notification.account.id,
|
||||
markedForDelete: markForDelete,
|
||||
markedForDelete: false,
|
||||
status: notification.status ? notification.status.id : null,
|
||||
report: notification.report ? fromJS(notification.report) : null,
|
||||
event: notification.event ? fromJS(notification.event) : null,
|
||||
@@ -76,7 +76,7 @@ const normalizeNotification = (state, notification, usePendingItems) => {
|
||||
}
|
||||
|
||||
if (usePendingItems || !state.get('pendingItems').isEmpty()) {
|
||||
return state.update('pendingItems', list => list.unshift(notificationToMap(notification, markNewForDelete))).update('unread', unread => unread + 1);
|
||||
return state.update('pendingItems', list => list.unshift(notificationToMap(notification).set('markForDelete', markNewForDelete))).update('unread', unread => unread + 1);
|
||||
}
|
||||
|
||||
if (shouldCountUnreadNotifications(state)) {
|
||||
@@ -90,7 +90,7 @@ const normalizeNotification = (state, notification, usePendingItems) => {
|
||||
list = list.take(20);
|
||||
}
|
||||
|
||||
return list.unshift(notificationToMap(notification, markNewForDelete));
|
||||
return list.unshift(notificationToMap(notification).set('markForDelete', markNewForDelete));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -104,7 +104,7 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingMore
|
||||
|
||||
const markNewForDelete = state.get('markNewForDelete');
|
||||
const lastReadId = state.get('lastReadId');
|
||||
const newItems = ImmutableList(notifications.map((notification) => notificationToMap(notification, markNewForDelete)));
|
||||
const newItems = ImmutableList(notifications.map((notification) => notificationToMap(notification).set('markForDelete', markNewForDelete)));
|
||||
|
||||
return state.withMutations(mutable => {
|
||||
if (!newItems.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user