mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 08:48:53 +00:00
[Glitch] Add automatic notification polling for grouped notifications
Port d67e11733e to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
} from 'flavours/glitch/api_types/notifications';
|
||||
import { allNotificationTypes } from 'flavours/glitch/api_types/notifications';
|
||||
import type { ApiStatusJSON } from 'flavours/glitch/api_types/statuses';
|
||||
import { usePendingItems } from 'flavours/glitch/initial_state';
|
||||
import type { NotificationGap } from 'flavours/glitch/reducers/notification_groups';
|
||||
import {
|
||||
selectSettingsNotificationsExcludedTypes,
|
||||
@@ -103,6 +104,28 @@ export const fetchNotificationsGap = createDataLoadingThunk(
|
||||
},
|
||||
);
|
||||
|
||||
export const pollRecentNotifications = createDataLoadingThunk(
|
||||
'notificationGroups/pollRecentNotifications',
|
||||
async (_params, { getState }) => {
|
||||
return apiFetchNotifications({
|
||||
max_id: undefined,
|
||||
// In slow mode, we don't want to include notifications that duplicate the already-displayed ones
|
||||
since_id: usePendingItems
|
||||
? getState().notificationGroups.groups.find(
|
||||
(group) => group.type !== 'gap',
|
||||
)?.page_max_id
|
||||
: undefined,
|
||||
});
|
||||
},
|
||||
({ notifications, accounts, statuses }, { dispatch }) => {
|
||||
dispatch(importFetchedAccounts(accounts));
|
||||
dispatch(importFetchedStatuses(statuses));
|
||||
dispatchAssociatedRecords(dispatch, notifications);
|
||||
|
||||
return { notifications };
|
||||
},
|
||||
);
|
||||
|
||||
export const processNewNotificationForGroups = createAppAsyncThunk(
|
||||
'notificationGroups/processNew',
|
||||
(notification: ApiNotificationJSON, { dispatch, getState }) => {
|
||||
|
||||
Reference in New Issue
Block a user