This commit is contained in:
Josh Hawkins
2026-09-30 11:22:15 -05:00
parent c4fdbdf541
commit 84d8c82a8c
6 changed files with 76 additions and 3 deletions
@@ -150,6 +150,37 @@ test.describe("live stream order and transcoded streams @medium", () => {
).toEqual(["Main", "Sub"]);
});
test("save all keeps a reorder made on another page", async ({
frigateApp,
}) => {
const capture = await installRoutes(frigateApp.page);
await frigateApp.goto(SETTINGS_URL);
await expect
.poll(() => streamNames(frigateApp.page))
.toEqual(["Sub", "Main"]);
await dragRow(frigateApp.page, 1, 0);
await expect
.poll(() => streamNames(frigateApp.page))
.toEqual(["Main", "Sub"]);
await frigateApp.page.getByText("Snapshots", { exact: true }).click();
await frigateApp.page.getByRole("button", { name: "Save All" }).click();
await expect.poll(() => capture.saved()).not.toBeNull();
const saved = capture.saved() as {
replace_paths: string[];
config_data: {
cameras: { front_door: { live: { streams: Record<string, string> } } };
};
};
expect(saved.replace_paths).toEqual(["cameras.front_door.live.streams"]);
expect(
Object.keys(saved.config_data.cameras.front_door.live.streams),
).toEqual(["Main", "Sub"]);
});
test("enabling transcoding saves the shown source", async ({
frigateApp,
}) => {
@@ -484,10 +484,13 @@ export function LiveStreamsField(props: FieldProps) {
);
// Auto order commits after measuring, so edits made meanwhile must survive
// and a camera switched to meanwhile must not receive the result
const dataRef = useRef(data);
const cameraRef = useRef(camera);
useEffect(() => {
dataRef.current = data;
}, [data]);
cameraRef.current = camera;
}, [data, camera]);
const [measurement, setMeasurement] = useState<{
data: LiveStreamsData;
@@ -527,6 +530,11 @@ export function LiveStreamsField(props: FieldProps) {
}),
);
if (cameraRef.current !== camera) {
setMeasuring(false);
return;
}
const next = Object.fromEntries(measured);
const latest = dataRef.current;
setMeasurement({ data: latest, transcode, rates: next });
+3
View File
@@ -875,6 +875,9 @@ export default function Settings() {
requires_restart: payload.needsRestart ? 1 : 0,
update_topic: payload.updateTopic,
config_data: configData,
...(payload.replacePaths?.length
? { replace_paths: payload.replacePaths }
: {}),
});
if (payload.needsRestart) {
+11 -1
View File
@@ -556,6 +556,7 @@ export interface SectionSavePayload {
updateTopic: string | undefined;
needsRestart: boolean;
pendingDataKey: string;
replacePaths?: string[];
}
// ---------------------------------------------------------------------------
@@ -765,7 +766,13 @@ export function prepareSectionSavePayload(opts: {
);
// Build overrides
const overrides = buildOverrides(pendingData, rawData, effectiveDefaults);
const orderedMaps = sectionConfig.orderedMaps ?? [];
const overrides = applyOrderedMaps(
buildOverrides(pendingData, rawData, effectiveDefaults),
pendingData,
rawData,
orderedMaps,
);
const sanitizedOverrides = sanitizeOverridesForSection(
schemaSection,
level,
@@ -815,6 +822,9 @@ export function prepareSectionSavePayload(opts: {
updateTopic,
needsRestart,
pendingDataKey,
replacePaths: changedOrderedMapPaths(pendingData, rawData, orderedMaps).map(
(path) => `${basePath}.${path}`,
),
};
}