Add ability to group follow notifications in WebUI (#32520)
This commit is contained in:
parent
acc1973f3a
commit
6c87c76e18
8 changed files with 48 additions and 17 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue