0
0
Fork 0

Add ability to group follow notifications in WebUI (#32520)

This commit is contained in:
Renaud Chaput 2024-10-16 10:33:11 +02:00 committed by GitHub
parent acc1973f3a
commit 6c87c76e18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 17 deletions

View file

@ -21,7 +21,6 @@ import {
unmountNotifications,
refreshStaleNotificationGroups,
pollRecentNotifications,
shouldGroupNotificationType,
} from 'mastodon/actions/notification_groups';
import {
disconnectTimeline,
@ -30,6 +29,7 @@ import {
import type {
ApiNotificationJSON,
ApiNotificationGroupJSON,
NotificationType,
} from 'mastodon/api_types/notifications';
import { compareId } from 'mastodon/compare_id';
import { usePendingItems } from 'mastodon/initial_state';
@ -205,8 +205,9 @@ function mergeGapsAround(
function processNewNotification(
groups: NotificationGroupsState['groups'],
notification: ApiNotificationJSON,
groupedTypes: NotificationType[],
) {
if (!shouldGroupNotificationType(notification.type)) {
if (!groupedTypes.includes(notification.type)) {
notification = {
...notification,
group_key: `ungrouped-${notification.id}`,
@ -476,11 +477,13 @@ export const notificationGroupsReducer = createReducer<NotificationGroupsState>(
trimNotifications(state);
})
.addCase(processNewNotificationForGroups.fulfilled, (state, action) => {
const notification = action.payload;
if (notification) {
if (action.payload) {
const { notification, groupedTypes } = action.payload;
processNewNotification(
usePendingItems ? state.pendingGroups : state.groups,
notification,
groupedTypes,
);
updateLastReadId(state);
trimNotifications(state);