diff --git a/app/javascript/mastodon/actions/notification_groups.ts b/app/javascript/mastodon/actions/notification_groups.ts index ccd5d3bf71..34e62054c6 100644 --- a/app/javascript/mastodon/actions/notification_groups.ts +++ b/app/javascript/mastodon/actions/notification_groups.ts @@ -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 }); diff --git a/app/javascript/mastodon/actions/notifications_typed.ts b/app/javascript/mastodon/actions/notifications_typed.ts index 176362f4b1..88d942d45e 100644 --- a/app/javascript/mastodon/actions/notifications_typed.ts +++ b/app/javascript/mastodon/actions/notifications_typed.ts @@ -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; }) => ({ diff --git a/app/javascript/mastodon/api/notifications.ts b/app/javascript/mastodon/api/notifications.ts index 97f5fd13cf..abc83882b1 100644 --- a/app/javascript/mastodon/api/notifications.ts +++ b/app/javascript/mastodon/api/notifications.ts @@ -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({ + const response = await api().request({ method: 'GET', url: forceUrl ?? '/api/v2_alpha/notifications', params, diff --git a/app/javascript/mastodon/api_types/notifications.ts b/app/javascript/mastodon/api_types/notifications.ts index e60c0e1821..d7cbbca73b 100644 --- a/app/javascript/mastodon/api_types/notifications.ts +++ b/app/javascript/mastodon/api_types/notifications.ts @@ -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 diff --git a/app/javascript/mastodon/models/notification_group.ts b/app/javascript/mastodon/models/notification_group.ts index 4dc7229c31..629da44be4 100644 --- a/app/javascript/mastodon/models/notification_group.ts +++ b/app/javascript/mastodon/models/notification_group.ts @@ -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],