From a8085a79fd0d1e1c53627560e482bd4bdcde6af1 Mon Sep 17 00:00:00 2001 From: Jagger <634750802@qq.com> Date: Thu, 25 Apr 2024 15:23:00 +0800 Subject: [PATCH] fix notification --- .../DiscourseNotification.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/site-components/src/components/discourse-notification/DiscourseNotification.tsx b/packages/site-components/src/components/discourse-notification/DiscourseNotification.tsx index 403d6c9..1bd6a41 100644 --- a/packages/site-components/src/components/discourse-notification/DiscourseNotification.tsx +++ b/packages/site-components/src/components/discourse-notification/DiscourseNotification.tsx @@ -90,19 +90,23 @@ const DiscourseNotification = ({ notification, wrap, markRead }: DiscourseNotifi } - if (Object.keys(notification.data).length !== 0) { - if (notification.post_number) { - result = renderTopicNotification(notification as AsktugNotification); - } else { - result = { - el: {notification.fancy_title}, - url: undefined, + if (!result) { + if (Object.keys(notification.data).length !== 0) { + if (notification.post_number) { + result = renderTopicNotification(notification as AsktugNotification); } } } - let el = result?.el - const url = result?.url ?? '#'; + if (!result) { + result = { + el: {notification.fancy_title ?? `未知通知类型(${notification.notification_type})`}, + url: undefined, + } + } + + let el = result.el + const url = result.url ?? '#'; const onClick = useCallback((event) => { if (!notification.read) { @@ -110,10 +114,6 @@ const DiscourseNotification = ({ notification, wrap, markRead }: DiscourseNotifi } }, [notification.read, notification.id, markRead]) - if (!el) { - el = <>{notification.fancy_title ?? `未知通知类型(${notification.notification_type})`} - } - el = {el}   el = React.cloneElement(wrap ? wrap(el) : el, { className: classnames('ti-asktug-notification', { 'ti-asktug-notification-read': notification.read }),