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