From 4fede554e4dcdca072e650160ea35c7167df39a0 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 5 Sep 2023 09:19:11 +0800 Subject: [PATCH] Handle admin notifications & unhandled ones --- src/components/icon.jsx | 2 ++ src/components/notification.jsx | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/icon.jsx b/src/components/icon.jsx index 47599177..34ed5e06 100644 --- a/src/components/icon.jsx +++ b/src/components/icon.jsx @@ -95,6 +95,8 @@ export const ICONS = { 'arrow-down-circle': () => import('@iconify-icons/mingcute/arrow-down-circle-line'), clipboard: () => import('@iconify-icons/mingcute/clipboard-line'), + 'account-edit': () => import('@iconify-icons/mingcute/user-edit-line'), + 'account-warning': () => import('@iconify-icons/mingcute/user-warning-line'), }; function Icon({ diff --git a/src/components/notification.jsx b/src/components/notification.jsx index 5b26aa74..0ed2d85a 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -18,6 +18,8 @@ const NOTIFICATION_ICONS = { favourite: 'heart', poll: 'poll', update: 'pencil', + 'admin.signup': 'account-edit', + 'admin.report': 'account-warning', }; /* @@ -54,6 +56,8 @@ const contentText = { 'favourite+reblog+account': (count) => `boosted & favourited ${count} of your posts.`, 'favourite+reblog_reply': 'boosted & favourited your reply.', + 'admin.signup': 'signed up.', + 'admin.report': 'reported a post.', }; function Notification({ notification, instance, reload, isStatic }) { @@ -102,9 +106,14 @@ function Notification({ notification, instance, reload, isStatic }) { } else { text = contentText[type]; } - } else { + } else if (contentText[type]) { text = contentText[type]; + } else { + // Anticipate unhandled notification types, possibly from Mastodon forks or non-Mastodon instances + // This surfaces the error to the user, hoping that users will report it + text = `[Unknown notification type: ${type}]`; } + if (typeof text === 'function') { text = text(_statuses?.length || _accounts?.length); } @@ -114,11 +123,14 @@ function Notification({ notification, instance, reload, isStatic }) { return null; } + const formattedCreatedAt = + notification.createdAt && new Date(notification.createdAt).toLocaleString(); + return (
{type === 'favourite+reblog' ? ( <>