Merge commit '13ab4b54e2
' into upstream-20241204-15
This commit is contained in:
commit
a6a237bc8e
228 changed files with 2678 additions and 1266 deletions
|
@ -18,6 +18,7 @@ export const NOTIFICATIONS_GROUP_MAX_AVATARS = 8;
|
|||
interface BaseNotificationGroup
|
||||
extends Omit<BaseNotificationGroupJSON, 'sample_account_ids'> {
|
||||
sampleAccountIds: string[];
|
||||
partial: boolean;
|
||||
}
|
||||
|
||||
interface BaseNotificationWithStatus<Type extends NotificationWithStatusType>
|
||||
|
@ -173,6 +174,7 @@ export function createNotificationGroupFromJSON(
|
|||
return {
|
||||
statusId: statusId ?? undefined,
|
||||
sampleAccountIds,
|
||||
partial: false,
|
||||
...groupWithoutStatus,
|
||||
};
|
||||
}
|
||||
|
@ -196,6 +198,7 @@ export function createNotificationGroupFromJSON(
|
|||
statusId: statusId ?? undefined,
|
||||
sampleAccountIds,
|
||||
emojiReactionGroups: groups,
|
||||
partial: false,
|
||||
...groupWithoutStatus,
|
||||
};
|
||||
}
|
||||
|
@ -204,12 +207,14 @@ export function createNotificationGroupFromJSON(
|
|||
return {
|
||||
report: createReportFromJSON(report),
|
||||
sampleAccountIds,
|
||||
partial: false,
|
||||
...groupWithoutTargetAccount,
|
||||
};
|
||||
}
|
||||
case 'severed_relationships':
|
||||
return {
|
||||
...group,
|
||||
partial: false,
|
||||
event: createAccountRelationshipSeveranceEventFromJSON(group.event),
|
||||
sampleAccountIds,
|
||||
};
|
||||
|
@ -218,13 +223,16 @@ export function createNotificationGroupFromJSON(
|
|||
const { moderation_warning, ...groupWithoutModerationWarning } = group;
|
||||
return {
|
||||
...groupWithoutModerationWarning,
|
||||
partial: false,
|
||||
moderationWarning: createAccountWarningFromJSON(moderation_warning),
|
||||
sampleAccountIds,
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return {
|
||||
sampleAccountIds,
|
||||
partial: false,
|
||||
...group,
|
||||
};
|
||||
}
|
||||
|
@ -232,17 +240,17 @@ export function createNotificationGroupFromJSON(
|
|||
|
||||
export function createNotificationGroupFromNotificationJSON(
|
||||
notification: ApiNotificationJSON,
|
||||
) {
|
||||
): NotificationGroup {
|
||||
const group = {
|
||||
sampleAccountIds: [notification.account.id],
|
||||
group_key: notification.group_key,
|
||||
notifications_count: 1,
|
||||
type: notification.type,
|
||||
most_recent_notification_id: notification.id,
|
||||
page_min_id: notification.id,
|
||||
page_max_id: notification.id,
|
||||
latest_page_notification_at: notification.created_at,
|
||||
} as NotificationGroup;
|
||||
partial: true,
|
||||
};
|
||||
|
||||
switch (notification.type) {
|
||||
case 'favourite':
|
||||
|
@ -252,16 +260,22 @@ export function createNotificationGroupFromNotificationJSON(
|
|||
case 'status_reference':
|
||||
case 'poll':
|
||||
case 'update':
|
||||
return { ...group, statusId: notification.status?.id };
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
statusId: notification.status?.id,
|
||||
};
|
||||
case 'list_status':
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
statusId: notification.status?.id,
|
||||
list: notification.list,
|
||||
};
|
||||
case 'emoji_reaction':
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
statusId: notification.status?.id,
|
||||
emojiReactionGroups: createEmojiReactionGroupsFromJSON(
|
||||
notification.emoji_reaction,
|
||||
|
@ -269,10 +283,15 @@ export function createNotificationGroupFromNotificationJSON(
|
|||
),
|
||||
};
|
||||
case 'admin.report':
|
||||
return { ...group, report: createReportFromJSON(notification.report) };
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
report: createReportFromJSON(notification.report),
|
||||
};
|
||||
case 'severed_relationships':
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
event: createAccountRelationshipSeveranceEventFromJSON(
|
||||
notification.event,
|
||||
),
|
||||
|
@ -280,11 +299,15 @@ export function createNotificationGroupFromNotificationJSON(
|
|||
case 'moderation_warning':
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
moderationWarning: createAccountWarningFromJSON(
|
||||
notification.moderation_warning,
|
||||
),
|
||||
};
|
||||
default:
|
||||
return group;
|
||||
return {
|
||||
...group,
|
||||
type: notification.type,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue