mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-11 05:11:13 +03:00
Don't stay on motion search page when user cancels flow
This commit is contained in:
@@ -770,6 +770,34 @@ export default function MotionSearchView({
|
|||||||
};
|
};
|
||||||
}, [cancelMotionSearchJobViaBeacon]);
|
}, [cancelMotionSearchJobViaBeacon]);
|
||||||
|
|
||||||
|
const handleBack = useCallback(() => {
|
||||||
|
if (onBack) {
|
||||||
|
onBack();
|
||||||
|
} else {
|
||||||
|
navigate(-1);
|
||||||
|
}
|
||||||
|
}, [navigate, onBack]);
|
||||||
|
|
||||||
|
// Dismissing the entry dialog (escape / click outside) before a search has
|
||||||
|
// run leaves nothing behind it, so cancel the flow instead of revealing an
|
||||||
|
// empty page.
|
||||||
|
const handleSearchDialogOpenChange = useCallback(
|
||||||
|
(nextOpen: boolean) => {
|
||||||
|
if (
|
||||||
|
!nextOpen &&
|
||||||
|
!isSearching &&
|
||||||
|
!hasSearched &&
|
||||||
|
searchResults.length === 0
|
||||||
|
) {
|
||||||
|
handleBack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSearchDialogOpen(nextOpen);
|
||||||
|
},
|
||||||
|
[handleBack, hasSearched, isSearching, searchResults.length],
|
||||||
|
);
|
||||||
|
|
||||||
const handleNewSearch = useCallback(() => {
|
const handleNewSearch = useCallback(() => {
|
||||||
if (jobId && jobCamera) {
|
if (jobId && jobCamera) {
|
||||||
void cancelMotionSearchJob(jobId, jobCamera);
|
void cancelMotionSearchJob(jobId, jobCamera);
|
||||||
@@ -1238,7 +1266,7 @@ export default function MotionSearchView({
|
|||||||
<Toaster closeButton={true} position="top-center" />
|
<Toaster closeButton={true} position="top-center" />
|
||||||
<MotionSearchDialog
|
<MotionSearchDialog
|
||||||
open={isSearchDialogOpen}
|
open={isSearchDialogOpen}
|
||||||
onOpenChange={setIsSearchDialogOpen}
|
onOpenChange={handleSearchDialogOpenChange}
|
||||||
config={config}
|
config={config}
|
||||||
cameras={cameras}
|
cameras={cameras}
|
||||||
selectedCamera={selectedCamera}
|
selectedCamera={selectedCamera}
|
||||||
@@ -1276,7 +1304,7 @@ export default function MotionSearchView({
|
|||||||
className="flex items-center gap-2.5 rounded-lg"
|
className="flex items-center gap-2.5 rounded-lg"
|
||||||
aria-label={t("label.back", { ns: "common" })}
|
aria-label={t("label.back", { ns: "common" })}
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => (onBack ? onBack() : navigate(-1))}
|
onClick={handleBack}
|
||||||
>
|
>
|
||||||
<IoMdArrowRoundBack className="size-5 text-secondary-foreground" />
|
<IoMdArrowRoundBack className="size-5 text-secondary-foreground" />
|
||||||
{isDesktop && (
|
{isDesktop && (
|
||||||
|
|||||||
Reference in New Issue
Block a user