1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-15 07:09:03 +09:00
YuruToot/app/javascript/flavours/glitch/api/notifications.ts
Claire 24849cdb1f [Glitch] Add automatic notification polling for grouped notifications
Port d67e11733e to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2024-08-21 18:51:27 +02:00

27 lines
736 B
TypeScript

import api, { apiRequest, getLinks } from 'flavours/glitch/api';
import type { ApiNotificationGroupsResultJSON } from 'flavours/glitch/api_types/notifications';
export const apiFetchNotifications = async (params?: {
exclude_types?: string[];
max_id?: string;
since_id?: string;
}) => {
const response = await api().request<ApiNotificationGroupsResultJSON>({
method: 'GET',
url: '/api/v2_alpha/notifications',
params,
});
const { statuses, accounts, notification_groups } = response.data;
return {
statuses,
accounts,
notifications: notification_groups,
links: getLinks(response),
};
};
export const apiClearNotifications = () =>
apiRequest<undefined>('POST', 'v1/notifications/clear');