Merge commit '9e04007020
' into upstream-20240725
This commit is contained in:
commit
a99f174d98
322 changed files with 8093 additions and 1586 deletions
33
app/javascript/mastodon/api/notifications.ts
Normal file
33
app/javascript/mastodon/api/notifications.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import api, { apiRequest, getLinks } from 'mastodon/api';
|
||||
import type { ApiNotificationGroupJSON } from 'mastodon/api_types/notifications';
|
||||
import type { ApiStatusJSON } from 'mastodon/api_types/statuses';
|
||||
|
||||
const exceptInvalidNotifications = (
|
||||
notifications: ApiNotificationGroupJSON[],
|
||||
) => {
|
||||
return notifications.filter((n) => {
|
||||
if ('status' in n) {
|
||||
return (n.status as ApiStatusJSON | null) !== null;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
export const apiFetchNotifications = async (params?: {
|
||||
exclude_types?: string[];
|
||||
max_id?: string;
|
||||
}) => {
|
||||
const response = await api().request<ApiNotificationGroupJSON[]>({
|
||||
method: 'GET',
|
||||
url: '/api/v2_alpha/notifications',
|
||||
params,
|
||||
});
|
||||
|
||||
return {
|
||||
notifications: exceptInvalidNotifications(response.data),
|
||||
links: getLinks(response),
|
||||
};
|
||||
};
|
||||
|
||||
export const apiClearNotifications = () =>
|
||||
apiRequest<undefined>('POST', 'v1/notifications/clear');
|
Loading…
Add table
Add a link
Reference in a new issue