|
1 | 1 | import { type LoaderFunctionArgs, type ActionFunctionArgs, json } from "@remix-run/server-runtime"; |
2 | | -import { type MetaFunction, Form, useNavigation, useSubmit } from "@remix-run/react"; |
| 2 | +import { type MetaFunction, useFetcher, useRevalidator } from "@remix-run/react"; |
3 | 3 | import { BellAlertIcon } from "@heroicons/react/20/solid"; |
4 | 4 | import { IconAlarmSnooze as IconAlarmSnoozeBase, IconCircleDotted } from "@tabler/icons-react"; |
5 | 5 | import { parse } from "@conform-to/zod"; |
@@ -35,7 +35,7 @@ import { |
35 | 35 | ResizablePanelGroup, |
36 | 36 | } from "~/components/primitives/Resizable"; |
37 | 37 | import { AnimatePresence, motion } from "framer-motion"; |
38 | | -import { Suspense, useMemo, useState } from "react"; |
| 38 | +import { Suspense, useEffect, useMemo, useRef, useState } from "react"; |
39 | 39 | import { Spinner } from "~/components/primitives/Spinner"; |
40 | 40 | import { Paragraph } from "~/components/primitives/Paragraph"; |
41 | 41 | import { Callout } from "~/components/primitives/Callout"; |
@@ -76,7 +76,12 @@ import { CodeBlock } from "~/components/code/CodeBlock"; |
76 | 76 |
|
77 | 77 | import { Popover, PopoverArrowTrigger, PopoverContent } from "~/components/primitives/Popover"; |
78 | 78 | import { ErrorGroupActions } from "~/v3/services/errorGroupActions.server"; |
79 | | -import { ErrorStatusMenuItems, CustomIgnoreDialog } from "~/components/errors/ErrorStatusMenu"; |
| 79 | +import { |
| 80 | + ErrorStatusMenuItems, |
| 81 | + CustomIgnoreDialog, |
| 82 | + ignoreActionToastMessage, |
| 83 | +} from "~/components/errors/ErrorStatusMenu"; |
| 84 | +import { useToast } from "~/components/primitives/Toast"; |
80 | 85 |
|
81 | 86 | export const meta: MetaFunction<typeof loader> = ({ data }) => { |
82 | 87 | return [ |
@@ -729,15 +734,26 @@ function ErrorStatusDropdown({ |
729 | 734 | state: ErrorGroupState; |
730 | 735 | taskIdentifier: string; |
731 | 736 | }) { |
732 | | - const submit = useSubmit(); |
733 | | - const navigation = useNavigation(); |
| 737 | + const fetcher = useFetcher<{ ok?: boolean }>(); |
| 738 | + const revalidator = useRevalidator(); |
734 | 739 | const [popoverOpen, setPopoverOpen] = useState(false); |
735 | 740 | const [customIgnoreOpen, setCustomIgnoreOpen] = useState(false); |
736 | | - const isSubmitting = navigation.state !== "idle"; |
| 741 | + const isSubmitting = fetcher.state !== "idle"; |
| 742 | + const toast = useToast(); |
| 743 | + const pendingToast = useRef<string | undefined>(); |
| 744 | + |
| 745 | + useEffect(() => { |
| 746 | + if (fetcher.state === "idle" && fetcher.data?.ok && pendingToast.current) { |
| 747 | + toast.success(pendingToast.current); |
| 748 | + pendingToast.current = undefined; |
| 749 | + revalidator.revalidate(); |
| 750 | + } |
| 751 | + }, [fetcher.state, fetcher.data, toast, revalidator]); |
737 | 752 |
|
738 | 753 | const act = (data: Record<string, string>) => { |
739 | 754 | setPopoverOpen(false); |
740 | | - submit(data, { method: "post" }); |
| 755 | + pendingToast.current = ignoreActionToastMessage(data); |
| 756 | + fetcher.submit(data, { method: "post" }); |
741 | 757 | }; |
742 | 758 |
|
743 | 759 | return ( |
|
0 commit comments