[Glitch] Add added_to_collection and collection_updated notification types
Port 39c70649caf8237996b7acb2535c7c1b49c4c78a to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
68a2b592bf
commit
22a7f785f5
@ -3,6 +3,7 @@
|
||||
import type { AccountWarningAction } from 'flavours/glitch/models/notification_group';
|
||||
|
||||
import type { ApiAccountJSON } from './accounts';
|
||||
import type { ApiCollectionJSON } from './collections';
|
||||
import type { ApiReportJSON } from './reports';
|
||||
import type { ApiStatusJSON } from './statuses';
|
||||
|
||||
@ -22,6 +23,8 @@ export const allNotificationTypes: NotificationType[] = [
|
||||
'moderation_warning',
|
||||
'severed_relationships',
|
||||
'annual_report',
|
||||
'added_to_collection',
|
||||
'collection_update',
|
||||
];
|
||||
|
||||
export type NotificationWithStatusType =
|
||||
@ -42,7 +45,9 @@ export type NotificationType =
|
||||
| 'severed_relationships'
|
||||
| 'admin.sign_up'
|
||||
| 'admin.report'
|
||||
| 'annual_report';
|
||||
| 'annual_report'
|
||||
| 'added_to_collection'
|
||||
| 'collection_update';
|
||||
|
||||
export interface BaseNotificationJSON {
|
||||
id: string;
|
||||
@ -83,6 +88,26 @@ interface ReportNotificationJSON extends BaseNotificationJSON {
|
||||
report: ApiReportJSON;
|
||||
}
|
||||
|
||||
interface AddedToCollectionNotificationGroupJSON extends BaseNotificationGroupJSON {
|
||||
type: 'added_to_collection';
|
||||
collection: ApiCollectionJSON;
|
||||
}
|
||||
|
||||
interface AddedToCollectionNotificationJSON extends BaseNotificationJSON {
|
||||
type: 'added_to_collection';
|
||||
collection: ApiCollectionJSON;
|
||||
}
|
||||
|
||||
interface CollectionUpdateNotificationGroupJSON extends BaseNotificationGroupJSON {
|
||||
type: 'collection_update';
|
||||
collection: ApiCollectionJSON;
|
||||
}
|
||||
|
||||
interface CollectionUpdateNotificationJSON extends BaseNotificationJSON {
|
||||
type: 'collection_update';
|
||||
collection: ApiCollectionJSON;
|
||||
}
|
||||
|
||||
type SimpleNotificationTypes = 'follow' | 'follow_request' | 'admin.sign_up';
|
||||
interface SimpleNotificationGroupJSON extends BaseNotificationGroupJSON {
|
||||
type: SimpleNotificationTypes;
|
||||
@ -146,7 +171,9 @@ export type ApiNotificationJSON =
|
||||
| ReportNotificationJSON
|
||||
| AccountRelationshipSeveranceNotificationJSON
|
||||
| NotificationWithStatusJSON
|
||||
| ModerationWarningNotificationJSON;
|
||||
| ModerationWarningNotificationJSON
|
||||
| AddedToCollectionNotificationJSON
|
||||
| CollectionUpdateNotificationJSON;
|
||||
|
||||
export type ApiNotificationGroupJSON =
|
||||
| SimpleNotificationGroupJSON
|
||||
@ -154,7 +181,9 @@ export type ApiNotificationGroupJSON =
|
||||
| AccountRelationshipSeveranceNotificationGroupJSON
|
||||
| NotificationGroupWithStatusJSON
|
||||
| ModerationWarningNotificationGroupJSON
|
||||
| AnnualReportNotificationGroupJSON;
|
||||
| AnnualReportNotificationGroupJSON
|
||||
| AddedToCollectionNotificationGroupJSON
|
||||
| CollectionUpdateNotificationGroupJSON;
|
||||
|
||||
export interface ApiNotificationGroupsResultJSON {
|
||||
accounts: ApiAccountJSON[];
|
||||
|
||||
@ -10,6 +10,8 @@ import type {
|
||||
} from 'flavours/glitch/api_types/notifications';
|
||||
import type { ApiReportJSON } from 'flavours/glitch/api_types/reports';
|
||||
|
||||
import type { ApiCollectionJSON } from '../api_types/collections';
|
||||
|
||||
// Maximum number of avatars displayed in a notification group
|
||||
// This corresponds to the max length of `group.sampleAccountIds`
|
||||
export const NOTIFICATIONS_GROUP_MAX_AVATARS = 8;
|
||||
@ -87,6 +89,15 @@ export interface NotificationGroupAdminReport extends BaseNotification<'admin.re
|
||||
report: Report;
|
||||
}
|
||||
|
||||
type Collection = ApiCollectionJSON;
|
||||
export interface NotificationGroupAddedToCollection extends BaseNotification<'added_to_collection'> {
|
||||
collection: Collection;
|
||||
}
|
||||
|
||||
export interface NotificationGroupCollectionUpdate extends BaseNotification<'collection_update'> {
|
||||
collection: Collection;
|
||||
}
|
||||
|
||||
export type NotificationGroup =
|
||||
| NotificationGroupFavourite
|
||||
| NotificationGroupReblog
|
||||
@ -102,7 +113,9 @@ export type NotificationGroup =
|
||||
| NotificationGroupSeveredRelationships
|
||||
| NotificationGroupAdminSignUp
|
||||
| NotificationGroupAdminReport
|
||||
| NotificationGroupAnnualReport;
|
||||
| NotificationGroupAnnualReport
|
||||
| NotificationGroupAddedToCollection
|
||||
| NotificationGroupCollectionUpdate;
|
||||
|
||||
function createReportFromJSON(reportJSON: ApiReportJSON): Report {
|
||||
const { target_account, ...report } = reportJSON;
|
||||
@ -249,6 +262,13 @@ export function createNotificationGroupFromNotificationJSON(
|
||||
notification.moderation_warning,
|
||||
),
|
||||
};
|
||||
case 'added_to_collection':
|
||||
case 'collection_update':
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
collection: notification.collection,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
...group,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user