diff --git a/web/src/components/overlay/detail/SearchDetailDialog.tsx b/web/src/components/overlay/detail/SearchDetailDialog.tsx index 703f9d13a..296e280c7 100644 --- a/web/src/components/overlay/detail/SearchDetailDialog.tsx +++ b/web/src/components/overlay/detail/SearchDetailDialog.tsx @@ -45,6 +45,8 @@ import { import { ReviewSegment } from "@/types/review"; import { useNavigate } from "react-router-dom"; import Chip from "@/components/indicators/Chip"; +import { capitalizeFirstLetter } from "@/utils/stringUtil"; +import useGlobalMutation from "@/hooks/use-global-mutate"; const SEARCH_TABS = [ "details", @@ -232,6 +234,10 @@ function ObjectDetailsTab({ }: ObjectDetailsTabProps) { const apiHost = useApiHost(); + // mutation / revalidation + + const mutate = useGlobalMutation(); + // data const [desc, setDesc] = useState(search?.data.description); @@ -282,6 +288,13 @@ function ObjectDetailsTab({ position: "top-center", }); } + mutate( + (key) => + typeof key === "string" && + (key.includes("events") || + key.includes("events/search") || + key.includes("explore")), + ); }) .catch(() => { toast.error("Failed to update the description", { @@ -289,7 +302,7 @@ function ObjectDetailsTab({ }); setDesc(search.data.description); }); - }, [desc, search]); + }, [desc, search, mutate]); const regenerateDescription = useCallback(() => { if (!search) { @@ -300,18 +313,24 @@ function ObjectDetailsTab({ .put(`events/${search.id}/description/regenerate`) .then((resp) => { if (resp.status == 200) { - toast.success("Description regeneration requested.", { - position: "top-center", - }); + toast.success( + `A new description has been requested from ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")}. Depending on the speed of your provider, the new description may take some time to regenerate.`, + { + position: "top-center", + duration: 7000, + }, + ); } }) .catch(() => { - toast.error("Failed to call generative AI for a new description", { - position: "top-center", - }); - setDesc(search.data.description); + toast.error( + `Failed to call ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")} for a new description`, + { + position: "top-center", + }, + ); }); - }, [search]); + }, [search, config]); return (