Skip to content

Commit 67a45e9

Browse files
committed
fix(update): dismiss better
1 parent bf8acb7 commit 67a45e9

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/workshop-app/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
138138
if (
139139
repoUpdates &&
140140
repoUpdates.remoteCommit &&
141-
mutedNotifications.includes(repoUpdates.remoteCommit)
141+
mutedNotifications.includes(`update-repo-${repoUpdates.remoteCommit}`)
142142
) {
143143
repoUpdates = { ...repoUpdates, updatesAvailable: false }
144144
}

packages/workshop-app/app/routes/admin+/update-repo.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function action({ request }: { request: Request }) {
1515
const id = formData.get('id')
1616

1717
if (intent === 'dismiss' && typeof id === 'string') {
18-
await muteNotification(id)
18+
await muteNotification(`update-repo-${id}`)
1919
return json({ type: 'dismissed' } as const)
2020
}
2121

@@ -59,6 +59,8 @@ export function UpdateToast({
5959
}) {
6060
const updateFetcher = useFetcher<typeof action>()
6161
const updateFetcherRef = useRef(updateFetcher)
62+
const dismissFetcher = useFetcher<typeof action>()
63+
const dismissFetcherRef = useRef(dismissFetcher)
6264
const { updatesAvailable, diffLink, remoteCommit } = repoUpdates
6365

6466
useEffect(() => {
@@ -84,7 +86,7 @@ export function UpdateToast({
8486
const formData = new FormData()
8587
formData.append('intent', 'dismiss')
8688
formData.append('id', remoteCommit)
87-
updateFetcherRef.current.submit(formData, {
89+
dismissFetcherRef.current.submit(formData, {
8890
method: 'post',
8991
action: '/admin/update-repo',
9092
})

0 commit comments

Comments
 (0)