mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-31 04:14:53 +03:00
fix fast refresh
This commit is contained in:
parent
3e708255a7
commit
718757fc60
@ -1,5 +1,5 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { createConfigSection } from "./BaseSection";
|
import { ConfigSection } from "./BaseSection";
|
||||||
import type { BaseSectionProps, SectionConfig } from "./BaseSection";
|
import type { BaseSectionProps, SectionConfig } from "./BaseSection";
|
||||||
import { getSectionConfig } from "@/utils/sectionConfigsUtils";
|
import { getSectionConfig } from "@/utils/sectionConfigsUtils";
|
||||||
|
|
||||||
@ -19,17 +19,10 @@ export function ConfigSectionTemplate({
|
|||||||
[sectionKey, level],
|
[sectionKey, level],
|
||||||
);
|
);
|
||||||
|
|
||||||
const SectionComponent = useMemo(
|
|
||||||
() =>
|
|
||||||
createConfigSection({
|
|
||||||
sectionPath: sectionKey,
|
|
||||||
defaultConfig,
|
|
||||||
}),
|
|
||||||
[sectionKey, defaultConfig],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SectionComponent
|
<ConfigSection
|
||||||
|
sectionPath={sectionKey}
|
||||||
|
defaultConfig={defaultConfig}
|
||||||
level={level}
|
level={level}
|
||||||
sectionConfig={sectionConfig ?? defaultConfig}
|
sectionConfig={sectionConfig ?? defaultConfig}
|
||||||
{...rest}
|
{...rest}
|
||||||
|
|||||||
@ -2,10 +2,11 @@
|
|||||||
// Reusable components for both global and camera-level settings
|
// Reusable components for both global and camera-level settings
|
||||||
|
|
||||||
export {
|
export {
|
||||||
createConfigSection,
|
ConfigSection,
|
||||||
type BaseSectionProps,
|
type BaseSectionProps,
|
||||||
type SectionConfig,
|
type SectionConfig,
|
||||||
type CreateSectionOptions,
|
type CreateSectionOptions,
|
||||||
|
type ConfigSectionProps,
|
||||||
} from "./BaseSection";
|
} from "./BaseSection";
|
||||||
export {
|
export {
|
||||||
ConfigSectionTemplate,
|
ConfigSectionTemplate,
|
||||||
|
|||||||
@ -39,7 +39,10 @@ import FrigatePlusSettingsView from "@/views/settings/FrigatePlusSettingsView";
|
|||||||
import MaintenanceSettingsView from "@/views/settings/MaintenanceSettingsView";
|
import MaintenanceSettingsView from "@/views/settings/MaintenanceSettingsView";
|
||||||
import GlobalConfigView from "@/views/settings/GlobalConfigView";
|
import GlobalConfigView from "@/views/settings/GlobalConfigView";
|
||||||
import CameraConfigView from "@/views/settings/CameraConfigView";
|
import CameraConfigView from "@/views/settings/CameraConfigView";
|
||||||
import { createSingleSectionPage } from "@/views/settings/SingleSectionPage";
|
import {
|
||||||
|
SingleSectionPage,
|
||||||
|
type SettingsPageProps,
|
||||||
|
} from "@/views/settings/SingleSectionPage";
|
||||||
import { useSearchEffect } from "@/hooks/use-overlay-state";
|
import { useSearchEffect } from "@/hooks/use-overlay-state";
|
||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||||
import { useInitialCameraState } from "@/api/ws";
|
import { useInitialCameraState } from "@/api/ws";
|
||||||
@ -93,16 +96,18 @@ const allSettingsViews = [
|
|||||||
] as const;
|
] as const;
|
||||||
type SettingsType = (typeof allSettingsViews)[number];
|
type SettingsType = (typeof allSettingsViews)[number];
|
||||||
|
|
||||||
const MqttSettingsPage = createSingleSectionPage({
|
const MqttSettingsPage = (props: SettingsPageProps) => (
|
||||||
sectionKey: "mqtt",
|
<SingleSectionPage sectionKey="mqtt" level="global" {...props} />
|
||||||
level: "global",
|
);
|
||||||
});
|
|
||||||
|
|
||||||
const CameraMqttSettingsPage = createSingleSectionPage({
|
const CameraMqttSettingsPage = (props: SettingsPageProps) => (
|
||||||
sectionKey: "mqtt",
|
<SingleSectionPage
|
||||||
level: "camera",
|
sectionKey="mqtt"
|
||||||
showOverrideIndicator: false,
|
level="camera"
|
||||||
});
|
showOverrideIndicator={false}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
const settingsGroups = [
|
const settingsGroups = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,17 +18,18 @@ export type SingleSectionPageOptions = {
|
|||||||
showOverrideIndicator?: boolean;
|
showOverrideIndicator?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createSingleSectionPage({
|
export type SingleSectionPageProps = SettingsPageProps &
|
||||||
|
SingleSectionPageOptions;
|
||||||
|
|
||||||
|
export function SingleSectionPage({
|
||||||
sectionKey,
|
sectionKey,
|
||||||
level,
|
level,
|
||||||
sectionConfig,
|
sectionConfig,
|
||||||
requiresRestart,
|
requiresRestart,
|
||||||
showOverrideIndicator = true,
|
showOverrideIndicator = true,
|
||||||
}: SingleSectionPageOptions) {
|
|
||||||
return function SingleSectionPage({
|
|
||||||
selectedCamera,
|
selectedCamera,
|
||||||
setUnsavedChanges,
|
setUnsavedChanges,
|
||||||
}: SettingsPageProps) {
|
}: SingleSectionPageProps) {
|
||||||
const sectionNamespace =
|
const sectionNamespace =
|
||||||
level === "camera" ? "config/cameras" : "config/global";
|
level === "camera" ? "config/cameras" : "config/global";
|
||||||
const { t, i18n } = useTranslation([
|
const { t, i18n } = useTranslation([
|
||||||
@ -71,5 +72,4 @@ export function createSingleSectionPage({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user