fix: Do not show the cameras menu with <= 1 camera (#1616)
This commit is contained in:
@@ -129,7 +129,7 @@ export class MenuButtonController {
|
|||||||
// Show all cameras in the menu rather than just cameras that support the
|
// Show all cameras in the menu rather than just cameras that support the
|
||||||
// current view for a less surprising UX.
|
// current view for a less surprising UX.
|
||||||
const menuCameraIDs = cameraManager.getStore().getCameraIDsWithCapability('menu');
|
const menuCameraIDs = cameraManager.getStore().getCameraIDsWithCapability('menu');
|
||||||
if (menuCameraIDs.size) {
|
if (menuCameraIDs.size > 1) {
|
||||||
const menuItems = Array.from(
|
const menuItems = Array.from(
|
||||||
cameraManager.getStore().getCameraConfigEntries(menuCameraIDs),
|
cameraManager.getStore().getCameraConfigEntries(menuCameraIDs),
|
||||||
([cameraID, config]) => {
|
([cameraID, config]) => {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import {
|
|||||||
createCameraConfig,
|
createCameraConfig,
|
||||||
createCameraManager,
|
createCameraManager,
|
||||||
createCapabilities,
|
createCapabilities,
|
||||||
createCardAPI,
|
|
||||||
createConfig,
|
createConfig,
|
||||||
createHASS,
|
createHASS,
|
||||||
createMediaCapabilities,
|
createMediaCapabilities,
|
||||||
@@ -115,7 +114,7 @@ describe('MenuButtonController', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('should have cameras menu', () => {
|
describe('should have cameras menu', () => {
|
||||||
it('with multiple cameras', () => {
|
it('should have cameras menu with multiple cameras', () => {
|
||||||
const cameraManager = createCameraManager();
|
const cameraManager = createCameraManager();
|
||||||
vi.mocked(cameraManager.getStore).mockReturnValue(
|
vi.mocked(cameraManager.getStore).mockReturnValue(
|
||||||
createStore([
|
createStore([
|
||||||
@@ -167,13 +166,18 @@ describe('MenuButtonController', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('without a visible camera', () => {
|
it('should not have cameras menu with <= 1 camera', () => {
|
||||||
const cameraManager = createCameraManager();
|
const cameraManager = createCameraManager();
|
||||||
vi.mocked(cameraManager.getStore).mockReturnValue(
|
vi.mocked(cameraManager.getStore).mockReturnValue(
|
||||||
createStore([
|
createStore([
|
||||||
{ cameraID: 'camera-1', config: createCameraConfig({ hide: true }) },
|
{ cameraID: 'camera-1', capabilities: createCapabilities({ menu: true }) },
|
||||||
|
{ cameraID: 'camera-3', capabilities: createCapabilities({ menu: false }) },
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
vi.mocked(cameraManager).getCameraMetadata.mockReturnValue({
|
||||||
|
title: 'title',
|
||||||
|
icon: 'icon',
|
||||||
|
});
|
||||||
const buttons = calculateButtons(controller, { cameraManager: cameraManager });
|
const buttons = calculateButtons(controller, { cameraManager: cameraManager });
|
||||||
|
|
||||||
expect(buttons).not.toEqual(
|
expect(buttons).not.toEqual(
|
||||||
|
|||||||
Reference in New Issue
Block a user