Compare commits

..
1 Commits
Author SHA1 Message Date
dependabot[bot]andGitHub 00a4b163fc Merge 4211250912 into 1ec511b66c 2026-06-26 21:15:54 -07:00
4 changed files with 34 additions and 69 deletions
@@ -24,9 +24,6 @@
}, },
"state": { "state": {
"submitted": "Submitted" "submitted": "Submitted"
},
"toast": {
"error": "Failed to submit to Frigate+. Please check your network connection and try again."
} }
} }
}, },
@@ -1251,42 +1251,30 @@ function ObjectDetailsTab({
return; return;
} }
try { falsePositive
const resp = falsePositive ? axios.put(`events/${search.id}/false_positive`)
? await axios.put(`events/${search.id}/false_positive`) : axios.post(`events/${search.id}/plus`, {
: await axios.post(`events/${search.id}/plus`, { include_annotation: 1,
include_annotation: 1, });
});
if (resp.status !== 200 || !resp.data?.success) { setState("submitted");
throw new Error(); setSearch({ ...search, plus_id: "new_upload" });
} mutate(
(key) => isEventsKey(key),
setState("submitted"); (currentData: SearchResult[][] | SearchResult[] | undefined) =>
setSearch({ ...search, plus_id: "new_upload" }); mapSearchResults(currentData, (event) =>
mutate( event.id === search.id
(key) => isEventsKey(key), ? { ...event, plus_id: "new_upload" }
(currentData: SearchResult[][] | SearchResult[] | undefined) => : event,
mapSearchResults(currentData, (event) => ),
event.id === search.id {
? { ...event, plus_id: "new_upload" } optimisticData: true,
: event, rollbackOnError: true,
), revalidate: false,
{ },
optimisticData: true, );
rollbackOnError: true,
revalidate: false,
},
);
} catch {
setState("reviewing");
toast.error(
t("explore.plus.review.toast.error", { ns: "components/dialog" }),
{ position: "top-center" },
);
}
}, },
[search, mutate, mapSearchResults, setSearch, isEventsKey, t], [search, mutate, mapSearchResults, setSearch, isEventsKey],
); );
const popoverContainerRef = useRef<HTMLDivElement | null>(null); const popoverContainerRef = useRef<HTMLDivElement | null>(null);
@@ -1225,15 +1225,11 @@ function LifecycleIconRow({
<DropdownMenuItem <DropdownMenuItem
className="cursor-pointer" className="cursor-pointer"
onSelect={async () => { onSelect={async () => {
try { const resp = await axios.post(
const resp = await axios.post( `/${item.camera}/plus/${item.timestamp + annotationOffset / 1000}`,
`/${item.camera}/plus/${item.timestamp + annotationOffset / 1000}`, );
);
if (resp.status !== 200) {
throw new Error();
}
if (resp && resp.status == 200) {
toast.success( toast.success(
t("toast.success.submittedFrigatePlus", { t("toast.success.submittedFrigatePlus", {
ns: "components/player", ns: "components/player",
@@ -1242,8 +1238,8 @@ function LifecycleIconRow({
position: "top-center", position: "top-center",
}, },
); );
} catch { } else {
toast.error( toast.success(
t("toast.error.submitFrigatePlusFailed", { t("toast.error.submitFrigatePlusFailed", {
ns: "components/player", ns: "components/player",
}), }),
@@ -10,7 +10,6 @@ import { isDesktop, isMobile, isSafari } from "react-device-detect";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import axios from "axios"; import axios from "axios";
import { toast } from "sonner";
import { useTranslation, Trans } from "react-i18next"; import { useTranslation, Trans } from "react-i18next";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import ActivityIndicator from "@/components/indicators/activity-indicator"; import ActivityIndicator from "@/components/indicators/activity-indicator";
@@ -49,28 +48,13 @@ export function FrigatePlusDialog({
const onSubmitToPlus = useCallback( const onSubmitToPlus = useCallback(
async (falsePositive: boolean) => { async (falsePositive: boolean) => {
if (!upload) return; if (!upload) return;
falsePositive
try { ? axios.put(`events/${upload.id}/false_positive`)
const resp = falsePositive : axios.post(`events/${upload.id}/plus`, { include_annotation: 1 });
? await axios.put(`events/${upload.id}/false_positive`) setState("submitted");
: await axios.post(`events/${upload.id}/plus`, { onEventUploaded();
include_annotation: 1,
});
if (resp.status !== 200 || !resp.data?.success) {
throw new Error();
}
setState("submitted");
onEventUploaded();
} catch {
setState("reviewing");
toast.error(t("explore.plus.review.toast.error"), {
position: "top-center",
});
}
}, },
[upload, onEventUploaded, t], [upload, onEventUploaded],
); );
const [imgRef, imgLoaded, onImgLoad] = useImageLoaded(); const [imgRef, imgLoaded, onImgLoad] = useImageLoaded();