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