Skip to content

Commit

Permalink
feat: notification toast dismiss button
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Feb 14, 2024
1 parent 5050bd4 commit af0e258
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions @web/components/notification-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function NotificationToaster() {
notification.blocks.find((b) => b.name === 'action_url')?.rendered

toast(
<div className="flex justify-between w-full">
<div className="flex justify-between w-full gap-1 items-center">
<div
dangerouslySetInnerHTML={{
__html: html,
Expand All @@ -112,7 +112,9 @@ function NotificationToaster() {
data-button=""
className="group-[.toast]:bg-primary group-[.toast]:text-primary-foreground"
onClick={() => {
toast.dismiss(id)
const url = new URL(actionUrl)
feedClient.markAsSeen(notification)
feedClient.markAsRead(notification)

if (url.origin === window.location.origin) {
Expand All @@ -124,7 +126,20 @@ function NotificationToaster() {
>
View
</button>
) : null}
) : (
<button
type="button"
data-button=""
className="group-[.toast]:bg-primary group-[.toast]:text-primary-foreground"
onClick={() => {
toast.dismiss(id)
feedClient.markAsSeen(notification)
feedClient.markAsRead(notification)
}}
>
Dismiss
</button>
)}
</div>,
{
id,
Expand Down

0 comments on commit af0e258

Please sign in to comment.