mirror of https://github.com/mastodon/mastodon.git
Rename notificationAPI JSON types for consistency
parent
3c23737a2d
commit
f4f77e163c
|
@ -1,8 +1,8 @@
|
|||
import { apiFetchNotifications } from 'mastodon/api/notifications';
|
||||
import type { ApiAccountJSON } from 'mastodon/api_types/accounts';
|
||||
import type {
|
||||
NotificationGroupJSON,
|
||||
NotificationJSON,
|
||||
ApiNotificationGroupJSON,
|
||||
ApiNotificationJSON,
|
||||
} from 'mastodon/api_types/notifications';
|
||||
import { allNotificationTypes } from 'mastodon/api_types/notifications';
|
||||
import type { ApiStatusJSON } from 'mastodon/api_types/statuses';
|
||||
|
@ -27,7 +27,7 @@ function excludeAllTypesExcept(filter: string) {
|
|||
|
||||
function dispatchAssociatedRecords(
|
||||
dispatch: AppDispatch,
|
||||
notifications: NotificationGroupJSON[] | NotificationJSON[],
|
||||
notifications: ApiNotificationGroupJSON[] | ApiNotificationJSON[],
|
||||
) {
|
||||
const fetchedAccounts: ApiAccountJSON[] = [];
|
||||
const fetchedStatuses: ApiStatusJSON[] = [];
|
||||
|
@ -77,7 +77,8 @@ export const fetchNotifications = createDataLoadingThunk(
|
|||
// recent notifications when doing the initial load
|
||||
const nextLink = links.refs.find((link) => link.rel === 'next');
|
||||
|
||||
const payload: (NotificationGroupJSON | NotificationGap)[] = notifications;
|
||||
const payload: (ApiNotificationGroupJSON | NotificationGap)[] =
|
||||
notifications;
|
||||
|
||||
if (nextLink) payload.push({ type: 'gap', loadUrl: nextLink.uri });
|
||||
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
import type { ApiAccountJSON } from '../api_types/accounts';
|
||||
// To be replaced once ApiNotificationJSON type exists
|
||||
interface FakeApiNotificationJSON {
|
||||
type: string;
|
||||
account: ApiAccountJSON;
|
||||
}
|
||||
import type { ApiNotificationJSON } from 'mastodon/api_types/notifications';
|
||||
|
||||
export const notificationsUpdate = createAction(
|
||||
'notifications/update',
|
||||
|
@ -13,7 +8,7 @@ export const notificationsUpdate = createAction(
|
|||
playSound,
|
||||
...args
|
||||
}: {
|
||||
notification: FakeApiNotificationJSON;
|
||||
notification: ApiNotificationJSON;
|
||||
usePendingItems: boolean;
|
||||
playSound: boolean;
|
||||
}) => ({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import api, { getLinks } from 'mastodon/api';
|
||||
import type { NotificationGroupJSON } from 'mastodon/api_types/notifications';
|
||||
import type { ApiNotificationGroupJSON } from 'mastodon/api_types/notifications';
|
||||
|
||||
export const apiFetchNotifications = async (
|
||||
params?: {
|
||||
|
@ -7,7 +7,7 @@ export const apiFetchNotifications = async (
|
|||
},
|
||||
forceUrl?: string,
|
||||
) => {
|
||||
const response = await api().request<NotificationGroupJSON[]>({
|
||||
const response = await api().request<ApiNotificationGroupJSON[]>({
|
||||
method: 'GET',
|
||||
url: forceUrl ?? '/api/v2_alpha/notifications',
|
||||
params,
|
||||
|
|
|
@ -130,14 +130,14 @@ interface AccountRelationshipSeveranceNotificationJSON
|
|||
event: ApiAccountRelationshipSeveranceEventJSON;
|
||||
}
|
||||
|
||||
export type NotificationJSON =
|
||||
export type ApiNotificationJSON =
|
||||
| SimpleNotificationJSON
|
||||
| ReportNotificationJSON
|
||||
| AccountRelationshipSeveranceNotificationJSON
|
||||
| NotificationWithStatusJSON
|
||||
| ModerationWarningNotificationJSON;
|
||||
|
||||
export type NotificationGroupJSON =
|
||||
export type ApiNotificationGroupJSON =
|
||||
| SimpleNotificationGroupJSON
|
||||
| ReportNotificationGroupJSON
|
||||
| AccountRelationshipSeveranceNotificationGroupJSON
|
||||
|
|
|
@ -2,8 +2,8 @@ import type {
|
|||
ApiAccountRelationshipSeveranceEventJSON,
|
||||
ApiAccountWarningJSON,
|
||||
BaseNotificationGroupJSON,
|
||||
NotificationGroupJSON,
|
||||
NotificationJSON,
|
||||
ApiNotificationGroupJSON,
|
||||
ApiNotificationJSON,
|
||||
NotificationType,
|
||||
NotificationWithStatusType,
|
||||
} from 'mastodon/api_types/notifications';
|
||||
|
@ -113,7 +113,7 @@ function createAccountRelationshipSeveranceEventFromJSON(
|
|||
}
|
||||
|
||||
export function createNotificationGroupFromJSON(
|
||||
groupJson: NotificationGroupJSON,
|
||||
groupJson: ApiNotificationGroupJSON,
|
||||
): NotificationGroup {
|
||||
const { sample_accounts, ...group } = groupJson;
|
||||
const sampleAccountsIds = sample_accounts.map((account) => account.id);
|
||||
|
@ -164,7 +164,7 @@ export function createNotificationGroupFromJSON(
|
|||
}
|
||||
|
||||
export function createNotificationGroupFromNotificationJSON(
|
||||
notification: NotificationJSON,
|
||||
notification: ApiNotificationJSON,
|
||||
) {
|
||||
const group = {
|
||||
sampleAccountsIds: [notification.account.id],
|
||||
|
|
Loading…
Reference in New Issue