diff --git a/src/components/ICONS.jsx b/src/components/ICONS.jsx index c0ad8bd4..98137774 100644 --- a/src/components/ICONS.jsx +++ b/src/components/ICONS.jsx @@ -106,4 +106,5 @@ export const ICONS = { copy: () => import('@iconify-icons/mingcute/copy-2-line'), quote: () => import('@iconify-icons/mingcute/quote-left-line'), settings: () => import('@iconify-icons/mingcute/settings-6-line'), + unlink: () => import('@iconify-icons/mingcute/unlink-line'), }; diff --git a/src/components/notification.jsx b/src/components/notification.jsx index aeeb1065..6b6205a8 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -25,6 +25,7 @@ const NOTIFICATION_ICONS = { update: 'pencil', 'admin.signup': 'account-edit', 'admin.report': 'account-warning', + severed_relationships: 'unlink', }; /* @@ -63,6 +64,14 @@ const contentText = { 'favourite+reblog_reply': 'boosted & liked your reply.', 'admin.sign_up': 'signed up.', 'admin.report': (targetAccount) => <>reported {targetAccount}, + severed_relationships: (name) => `Relationships with ${name} severed.`, +}; + +// account_suspension, domain_block, user_domain_block +const SEVERED_RELATIONSHIPS_TEXT = { + account_suspension: 'Account has been suspended.', + domain_block: 'Domain has been blocked.', + user_domain_block: 'You blocked this domain.', }; const AVATARS_LIMIT = 50; @@ -73,7 +82,8 @@ function Notification({ isStatic, disableContextMenu, }) { - const { id, status, account, report, _accounts, _statuses } = notification; + const { id, status, account, report, event, _accounts, _statuses } = + notification; let { type } = notification; // status = Attached when type of the notification is favourite, reblog, status, mention, poll, or update @@ -135,6 +145,11 @@ function Notification({ if (targetAccount) { text = text(); } + } else if (type === 'severed_relationships') { + const targetName = event?.targetName; + if (targetName) { + text = text(targetName); + } } } @@ -203,9 +218,11 @@ function Notification({ {' '} ) : ( - <> - {' '} - + account && ( + <> + {' '} + + ) )} )} @@ -224,6 +241,44 @@ function Notification({ {type === 'follow_request' && ( )} + {type === 'severed_relationships' && ( + <> +

+ + {event?.purge ? ( + 'Purged by administrators.' + ) : ( + <> + {event.relationshipsCount} relationship + {event.relationshipsCount === 1 ? '' : 's'} + {!!event.createdAt && ( + <> + {' '} + •{' '} + + + )} + + )} + +
+ {SEVERED_RELATIONSHIPS_TEXT[event.type]} +

+

+ + View + +

+ + )} )} {_accounts?.length > 1 && ( diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 7a24a386..a629024a 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -198,6 +198,7 @@ function Notifications({ columnMode }) { setUIState('default'); } catch (e) { + console.error(e); setUIState('error'); } })(); diff --git a/src/utils/group-notifications.jsx b/src/utils/group-notifications.jsx index 132fd32a..630f2d4c 100644 --- a/src/utils/group-notifications.jsx +++ b/src/utils/group-notifications.jsx @@ -63,11 +63,11 @@ function groupNotifications(notifications) { mappedNotification.id += `-${id}`; } } else { - account._types = [type]; + if (account) account._types = [type]; let n = (notificationsMap[key] = { ...notification, type: virtualType, - _accounts: [account], + _accounts: account ? [account] : [], }); cleanNotifications[j++] = n; }