Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ui): mark as read when a link in a notification is clicked #4108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions ee/tabby-ui/components/notification-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { HTMLAttributes, useMemo } from 'react'
import { TabsContent } from '@radix-ui/react-tabs'
import { AnimatePresence, motion } from 'framer-motion'
import moment from 'moment'
import useSWR from 'swr'
import { useQuery } from 'urql'
Expand Down Expand Up @@ -135,18 +136,20 @@ function NotificationList({

return (
<div className="space-y-2">
{notifications?.map((item, index) => {
return (
<div key={item.id}>
<NotificationItem data={item} />
<Separator
className={cn('my-3', {
hidden: index === len - 1
})}
/>
</div>
)
})}
<AnimatePresence>
{notifications?.map((item, index) => {
return (
<motion.div layout key={item.id}>
<NotificationItem data={item} />
<Separator
className={cn('my-3', {
hidden: index === len - 1
})}
/>
</motion.div>
)
})}
</AnimatePresence>
</div>
)
}
Expand All @@ -171,6 +174,17 @@ function NotificationItem({ data }: NotificationItemProps) {
'prose max-w-none break-words text-sm dark:prose-invert prose-p:my-1 prose-p:leading-relaxed',
{ 'unread-notification': !data.read }
)}
components={{
a: props => (
<a
{...props}
onClick={e => {
onClickMarkRead()
props.onClick?.(e)
}}
/>
)
}}
>
{data.content}
</MemoizedReactMarkdown>
Expand Down