catstodon/app/javascript/flavours/glitch/actions/notifications_migration.tsx
Claire bdc0e0d27e [Glitch] Fix non-grouped notifications not loading on page load
Port 9ba7c90151 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2024-08-20 19:42:36 +02:00

18 lines
650 B
TypeScript

import { createAppAsyncThunk } from 'flavours/glitch/store';
import { fetchNotifications } from './notification_groups';
import { expandNotifications } from './notifications';
export const initializeNotifications = createAppAsyncThunk(
'notifications/initialize',
(_, { dispatch, getState }) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
const enableBeta = getState().settings.getIn(
['notifications', 'groupingBeta'],
false,
) as boolean;
if (enableBeta) void dispatch(fetchNotifications());
else void dispatch(expandNotifications({}));
},
);