mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 21:44:13 +03:00
suppress double toasts
This commit is contained in:
parent
b88bf2f08d
commit
7e4f95c10d
@ -334,7 +334,8 @@ export default function Step2ProbeOrSnapshot({
|
|||||||
[generateDynamicStreamUrl],
|
[generateDynamicStreamUrl],
|
||||||
);
|
);
|
||||||
|
|
||||||
const testConnection = useCallback(async () => {
|
const testConnection = useCallback(
|
||||||
|
async (showToast = true) => {
|
||||||
const streamUrl = await generateStreamUrl(wizardData);
|
const streamUrl = await generateStreamUrl(wizardData);
|
||||||
|
|
||||||
if (!streamUrl) {
|
if (!streamUrl) {
|
||||||
@ -363,13 +364,18 @@ export default function Step2ProbeOrSnapshot({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
toast.success(t("cameraWizard.step2.testSuccess"));
|
toast.success(t("cameraWizard.step2.testSuccess"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const errMsg = result?.error || "Unable to probe stream";
|
const errMsg = result?.error || "Unable to probe stream";
|
||||||
setTestResult({
|
setTestResult({
|
||||||
success: false,
|
success: false,
|
||||||
error: errMsg,
|
error: errMsg,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
toast.error(
|
toast.error(
|
||||||
t("cameraWizard.commonErrors.testFailed", { error: errMsg }),
|
t("cameraWizard.commonErrors.testFailed", { error: errMsg }),
|
||||||
{
|
{
|
||||||
@ -377,6 +383,7 @@ export default function Step2ProbeOrSnapshot({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const axiosError = error as {
|
const axiosError = error as {
|
||||||
response?: { data?: { message?: string; detail?: string } };
|
response?: { data?: { message?: string; detail?: string } };
|
||||||
@ -391,17 +398,22 @@ export default function Step2ProbeOrSnapshot({
|
|||||||
success: false,
|
success: false,
|
||||||
error: errorMessage,
|
error: errorMessage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
toast.error(
|
toast.error(
|
||||||
t("cameraWizard.commonErrors.testFailed", { error: errorMessage }),
|
t("cameraWizard.commonErrors.testFailed", { error: errorMessage }),
|
||||||
{
|
{
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setIsTesting(false);
|
setIsTesting(false);
|
||||||
setTestStatus("");
|
setTestStatus("");
|
||||||
}
|
}
|
||||||
}, [wizardData, generateStreamUrl, t, onUpdate, probeUri]);
|
},
|
||||||
|
[wizardData, generateStreamUrl, t, onUpdate, probeUri],
|
||||||
|
);
|
||||||
|
|
||||||
const handleContinue = useCallback(() => {
|
const handleContinue = useCallback(() => {
|
||||||
onNext();
|
onNext();
|
||||||
@ -416,7 +428,8 @@ export default function Step2ProbeOrSnapshot({
|
|||||||
if (probeMode) {
|
if (probeMode) {
|
||||||
probeCamera();
|
probeCamera();
|
||||||
} else {
|
} else {
|
||||||
testConnection();
|
// Auto-run the connection test but suppress toasts to avoid duplicates
|
||||||
|
testConnection(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [hasStarted, probeMode, probeCamera, testConnection]);
|
}, [hasStarted, probeMode, probeCamera, testConnection]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user