Skip to content

Commit 687f066

Browse files
committed
fix(notifications): avoid over-notifying
1 parent a92e11f commit 687f066

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

packages/workshop-app/app/routes/admin+/notifications.server.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const NOTIFICATIONS: Array<Notification> = [
2222
]
2323

2424
export async function getUnmutedNotifications() {
25+
if (ENV.EPICSHOP_DEPLOYED) return []
26+
2527
const muted = await getMutedNotifications()
2628

2729
const visibleNotifications = NOTIFICATIONS.filter((n) => {

packages/workshop-app/app/routes/admin+/notifications.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ export function Notifications({
2626
}) {
2727
const fetcher = useFetcher<typeof action>()
2828
const fetcherRef = useRef(fetcher)
29+
const toastedIds = useRef<Set<string>>(new Set())
2930

3031
useEffect(() => {
3132
for (const notification of unmutedNotifications) {
33+
if (toastedIds.current.has(notification.id)) continue
34+
toastedIds.current.add(notification.id)
35+
3236
toast.info(notification.title, {
37+
id: notification.id,
3338
description: (
3439
<div>
3540
<p>{notification.message}</p>

0 commit comments

Comments
 (0)