mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-29 11:26:49 +03:00
* migrate web to eslint 10 flat config ESLint 10 dropped `.eslintrc` support, so `.eslintrc.cjs` is replaced with `eslint.config.js` and the lint scripts no longer pass `--ext` or `--ignore-path`. typescript-eslint moves to 8, react-hooks to 7, and react-refresh to 0.5, and the unused jest and vitest-globals plugins are removed. Lint behaves as it did before: catch variables aren't checked, unused disable directives aren't reported, and rules newly added to the recommended sets are off until the code passes them. typescript-eslint 8 flags constants used only in `typeof`, so those are now exported, or replaced with a union type where the export would trip react-refresh. * fix lint findings from the eslint 10 recommended rules Remove the rule overrides from the flat config migration and fix what they were hiding. Unused catch bindings are dropped, 20 disable directives that suppressed nothing are removed (react-hooks 5.2 and 7.1.1 report identical exhaustive-deps findings with inline config ignored), dead initial values are dropped, short-circuit calls become if statements or optional calls, rethrown errors pass `cause`, and the disabled "No recordings" tooltip in `ReviewTimeline` is removed along with its memo and the `getRecordingAvailability` prop. The 3 react-refresh warnings for files that export contexts or classes are left for a later refactor.
79 lines
2.0 KiB
TypeScript
79 lines
2.0 KiB
TypeScript
// Build a config/set query fragment that removes `name` from a
|
|
// required_zones list on the given camera section (e.g. "snapshots",
|
|
// "mqtt", "objects.genai", "onvif.autotracking"), rebuilding the
|
|
// remaining entries. When removing the name empties the list, the
|
|
// required_zones key itself is deleted so the field reverts to its
|
|
// default instead of retaining the now-stale zone name. Returns an empty
|
|
// string when `name` is not present so unrelated sections are untouched.
|
|
export const removeRequiredZoneQuery = (
|
|
name: string,
|
|
camera: string,
|
|
section: string,
|
|
zones: string[],
|
|
) => {
|
|
const remaining = new Set<string>(zones || []);
|
|
|
|
if (!remaining.has(name)) {
|
|
return "";
|
|
}
|
|
|
|
remaining.delete(name);
|
|
|
|
const key = `cameras.${camera}.${section}.required_zones`;
|
|
|
|
if (remaining.size === 0) {
|
|
return `&${key}`;
|
|
}
|
|
|
|
return [...remaining].map((zone) => `&${key}=${zone}`).join("");
|
|
};
|
|
|
|
export const reviewQueries = (
|
|
name: string,
|
|
review_alerts: boolean,
|
|
review_detections: boolean,
|
|
camera: string,
|
|
alertsZones: string[],
|
|
detectionsZones: string[],
|
|
) => {
|
|
let same_alerts = false;
|
|
let same_detections = false;
|
|
|
|
const alerts = new Set<string>(alertsZones || []);
|
|
|
|
if (review_alerts) {
|
|
alerts.add(name);
|
|
} else {
|
|
same_alerts = !alerts.has(name);
|
|
alerts.delete(name);
|
|
}
|
|
|
|
let alertQueries = [...alerts]
|
|
.map((zone) => `&cameras.${camera}.review.alerts.required_zones=${zone}`)
|
|
.join("");
|
|
|
|
const detections = new Set<string>(detectionsZones || []);
|
|
|
|
if (review_detections) {
|
|
detections.add(name);
|
|
} else {
|
|
same_detections = !detections.has(name);
|
|
detections.delete(name);
|
|
}
|
|
|
|
let detectionQueries = [...detections]
|
|
.map(
|
|
(zone) => `&cameras.${camera}.review.detections.required_zones=${zone}`,
|
|
)
|
|
.join("");
|
|
|
|
if (!alertQueries && !same_alerts) {
|
|
alertQueries = `&cameras.${camera}.review.alerts`;
|
|
}
|
|
if (!detectionQueries && !same_detections) {
|
|
detectionQueries = `&cameras.${camera}.review.detections`;
|
|
}
|
|
|
|
return { alertQueries, detectionQueries };
|
|
};
|