mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 17:12:16 +03:00
Keep the input path when switching stream source modes and reset mode overrides across cameras
This commit is contained in:
@@ -170,6 +170,12 @@ export function CameraInputsField(props: FieldProps) {
|
|||||||
[go2rtcStreamNames],
|
[go2rtcStreamNames],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSourceModeByIndex((previous) =>
|
||||||
|
Object.keys(previous).length > 0 ? {} : previous,
|
||||||
|
);
|
||||||
|
}, [formContext?.cameraName]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOpenByIndex((previous) => {
|
setOpenByIndex((previous) => {
|
||||||
const next: Record<number, boolean> = {};
|
const next: Record<number, boolean> = {};
|
||||||
@@ -222,18 +228,12 @@ export function CameraInputsField(props: FieldProps) {
|
|||||||
const handleSourceModeChange = useCallback(
|
const handleSourceModeChange = useCallback(
|
||||||
(index: number, nextMode: StreamSourceMode) => {
|
(index: number, nextMode: StreamSourceMode) => {
|
||||||
const input = inputs[index];
|
const input = inputs[index];
|
||||||
const currentPath =
|
|
||||||
typeof input?.path === "string" ? input.path : undefined;
|
|
||||||
|
|
||||||
if (nextMode === "manual") {
|
// Only revert the preset we set ourselves; never clobber custom args.
|
||||||
// Only revert the preset we set ourselves; never clobber custom args.
|
// The path is left alone until a stream is picked, so switching modes
|
||||||
if (input?.input_args === RESTREAM_PRESET) {
|
// never discards a typed URL or empties a required field.
|
||||||
handleFieldValuesChange(index, { input_args: undefined });
|
if (nextMode === "manual" && input?.input_args === RESTREAM_PRESET) {
|
||||||
}
|
handleFieldValuesChange(index, { input_args: undefined });
|
||||||
} else if (!parseRestreamStreamName(currentPath)) {
|
|
||||||
// Entering restream with a non-restream path: clear it so the dropdown
|
|
||||||
// shows its placeholder until a stream is chosen.
|
|
||||||
handleFieldValuesChange(index, { path: undefined });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSourceModeByIndex((previous) => ({ ...previous, [index]: nextMode }));
|
setSourceModeByIndex((previous) => ({ ...previous, [index]: nextMode }));
|
||||||
|
|||||||
Reference in New Issue
Block a user