[Glitch] Fix follow notifications from streaming being grouped

Port 8ac00533ff to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
pull/2865/head
Renaud Chaput 2024-10-01 10:22:14 +02:00 committed by Claire
parent dfe851b476
commit 1b6bd585ab
2 changed files with 46 additions and 37 deletions

View File

@ -70,6 +70,10 @@ function dispatchAssociatedRecords(
const supportedGroupedNotificationTypes = ['favourite', 'reblog'];
export function shouldGroupNotificationType(type: string) {
return supportedGroupedNotificationTypes.includes(type);
}
export const fetchNotifications = createDataLoadingThunk(
'notificationGroups/fetch',
async (_params, { getState }) =>

View File

@ -21,6 +21,7 @@ import {
unmountNotifications,
refreshStaleNotificationGroups,
pollRecentNotifications,
shouldGroupNotificationType,
} from 'flavours/glitch/actions/notification_groups';
import {
disconnectTimeline,
@ -205,6 +206,7 @@ function processNewNotification(
groups: NotificationGroupsState['groups'],
notification: ApiNotificationJSON,
) {
if (shouldGroupNotificationType(notification.type)) {
const existingGroupIndex = groups.findIndex(
(group) =>
group.type !== 'gap' && group.group_key === notification.group_key,
@ -240,12 +242,15 @@ function processNewNotification(
mergeGapsAround(groups, existingGroupIndex);
groups.unshift(existingGroup);
return;
}
} else {
// Create a new group
}
}
// We have not found an existing group, create a new one
groups.unshift(createNotificationGroupFromNotificationJSON(notification));
}
}
function trimNotifications(state: NotificationGroupsState) {
if (state.scrolledToTop && state.groups.length > NOTIFICATIONS_TRIM_LIMIT) {