mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Fix switching camera group bug (#10478)
* give default group a name * use "default" as default value * optional param * fix string * clean up
This commit is contained in:
parent
df0291db5c
commit
c93b186eda
@ -52,7 +52,10 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
|
||||
|
||||
// groups
|
||||
|
||||
const [group, setGroup] = usePersistedOverlayState("cameraGroup");
|
||||
const [group, setGroup] = usePersistedOverlayState(
|
||||
"cameraGroup",
|
||||
"default" as string,
|
||||
);
|
||||
|
||||
const groups = useMemo(() => {
|
||||
if (!config) {
|
||||
@ -78,24 +81,24 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
|
||||
currentGroups={groups}
|
||||
/>
|
||||
|
||||
<Tooltip open={tooltip == "home"}>
|
||||
<Tooltip open={tooltip == "default"}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
className={
|
||||
group == undefined
|
||||
group == "default"
|
||||
? "text-selected bg-blue-900 focus:bg-blue-900 bg-opacity-60 focus:bg-opacity-60"
|
||||
: "text-muted-foreground bg-secondary focus:text-muted-foreground focus:bg-secondary"
|
||||
}
|
||||
size="xs"
|
||||
onClick={() => (group ? setGroup(undefined, true) : null)}
|
||||
onMouseEnter={() => (isDesktop ? showTooltip("home") : null)}
|
||||
onClick={() => (group ? setGroup("default", true) : null)}
|
||||
onMouseEnter={() => (isDesktop ? showTooltip("default") : null)}
|
||||
onMouseLeave={() => (isDesktop ? showTooltip(undefined) : null)}
|
||||
>
|
||||
<MdHome className="size-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="capitalize" side="right">
|
||||
Home
|
||||
All Cameras
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
{groups.map(([name, config]) => {
|
||||
@ -109,7 +112,7 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
|
||||
: "text-muted-foreground bg-secondary"
|
||||
}
|
||||
size="xs"
|
||||
onClick={() => setGroup(name, group != undefined)}
|
||||
onClick={() => setGroup(name, group != "default")}
|
||||
onMouseEnter={() => (isDesktop ? showTooltip(name) : null)}
|
||||
onMouseLeave={() => (isDesktop ? showTooltip(undefined) : null)}
|
||||
>
|
||||
|
@ -11,10 +11,13 @@ function Live() {
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
|
||||
const [selectedCameraName, setSelectedCameraName] = useOverlayState("camera");
|
||||
const [cameraGroup] = usePersistedOverlayState("cameraGroup");
|
||||
const [cameraGroup] = usePersistedOverlayState(
|
||||
"cameraGroup",
|
||||
"default" as string,
|
||||
);
|
||||
|
||||
const includesBirdseye = useMemo(() => {
|
||||
if (config && cameraGroup) {
|
||||
if (config && cameraGroup && cameraGroup != "default") {
|
||||
return config.camera_groups[cameraGroup].cameras.includes("birdseye");
|
||||
} else {
|
||||
return false;
|
||||
@ -26,7 +29,7 @@ function Live() {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (cameraGroup) {
|
||||
if (cameraGroup && cameraGroup != "default") {
|
||||
const group = config.camera_groups[cameraGroup];
|
||||
return Object.values(config.cameras)
|
||||
.filter((conf) => conf.enabled && group.cameras.includes(conf.name))
|
||||
|
Loading…
Reference in New Issue
Block a user