Skip to content

Commit

Permalink
fix notification
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Apr 25, 2024
1 parent d204d0f commit 30f3613
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,30 @@ const DiscourseNotification = ({ notification, wrap, markRead }: DiscourseNotifi
}
}

let el, url = result?.url ?? '#';
let el = result?.el
const url = result?.url ?? '#';

const onClick = useCallback((event) => {
if (!notification.read) {
markRead?.(notification.id)
}
}, [notification.read, notification.id, markRead])

if (result?.el) {
el = <span>{result?.el}&nbsp;&nbsp;<LuxonDuration className='ti-asktug-notification__time' from={notification.created_at} suffix='前'/></span>
const element = React.cloneElement(wrap ? wrap(el) : el, {
className: classnames('ti-asktug-notification', { 'ti-asktug-notification-read': notification.read }),
onClickCapture: onClick
})
return getLink(url, element)
if (!el) {
el = <>{notification.fancy_title ?? `未知通知类型(${notification.notification_type})`}</>
}

console.warn('unknown notification type: ', notification)
return null
el = <span>{el}&nbsp;&nbsp;<LuxonDuration className='ti-asktug-notification__time' from={notification.created_at} suffix='前'/></span>
el = React.cloneElement(wrap ? wrap(el) : el, {
className: classnames('ti-asktug-notification', { 'ti-asktug-notification-read': notification.read }),
onClickCapture: onClick
})

if (url) {
return getLink(url, el)
} else {
return el;
}
}

DiscourseNotification.displayName = 'TiSiteDiscourseNotification'
Expand Down

0 comments on commit 30f3613

Please sign in to comment.