Only import screenfull in a single place.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// TODO: Test HA state connection/disconnect logic in real life.
|
||||
// TODO: Should not need to import screenfull anywhere except the fullscreen manager.
|
||||
// TODO: executeMediaQueryForView should not need a HTMLElement host parameter see the view-manager.ts call in particular.
|
||||
// TODO: Split out zod schema and add tests for config parsing (e.g. view.scan.show_status argument was missing)
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { HomeAssistant } from 'custom-card-helpers';
|
||||
import { StyleInfo } from 'lit/directives/style-map';
|
||||
import screenfull from 'screenfull';
|
||||
import { CameraManager } from '../camera-manager/manager';
|
||||
import { FRIGATE_BUTTON_MENU_ICON } from '../const';
|
||||
import { localize } from '../localize/localize.js';
|
||||
@@ -19,6 +18,15 @@ import { MediaPlayerManager } from './card-controller/media-player-manager';
|
||||
import { MicrophoneManager } from './card-controller/microphone-manager';
|
||||
import { hasSubstream } from './substream';
|
||||
|
||||
export interface MenuButtonControllerOptions {
|
||||
currentMediaLoadedInfo?: MediaLoadedInfo | null;
|
||||
showCameraUIButton?: boolean;
|
||||
inFullscreenMode?: boolean;
|
||||
inExpandedMode?: boolean;
|
||||
microphoneManager?: MicrophoneManager | null;
|
||||
mediaPlayerController?: MediaPlayerManager | null;
|
||||
}
|
||||
|
||||
export class MenuButtonController {
|
||||
// Array of dynamic menu buttons to be added to menu.
|
||||
protected _dynamicMenuButtons: MenuButton[] = [];
|
||||
@@ -44,13 +52,7 @@ export class MenuButtonController {
|
||||
config: FrigateCardConfig,
|
||||
cameraManager: CameraManager,
|
||||
view: View,
|
||||
expanded: boolean,
|
||||
options?: {
|
||||
currentMediaLoadedInfo?: MediaLoadedInfo | null;
|
||||
showCameraUIButton?: boolean,
|
||||
microphoneManager?: MicrophoneManager | null;
|
||||
mediaPlayerController?: MediaPlayerManager | null;
|
||||
},
|
||||
options?: MenuButtonControllerOptions,
|
||||
): MenuButton[] {
|
||||
const visibleCameras = cameraManager.getStore().getVisibleCameras();
|
||||
const selectedCameraID = view.camera;
|
||||
@@ -294,26 +296,26 @@ export class MenuButtonController {
|
||||
});
|
||||
}
|
||||
|
||||
if (screenfull.isEnabled && !this._isBeingCasted()) {
|
||||
if (!this._isBeingCasted()) {
|
||||
buttons.push({
|
||||
icon: screenfull.isFullscreen ? 'mdi:fullscreen-exit' : 'mdi:fullscreen',
|
||||
icon: options?.inFullscreenMode ? 'mdi:fullscreen-exit' : 'mdi:fullscreen',
|
||||
...config.menu.buttons.fullscreen,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
title: localize('config.menu.buttons.fullscreen'),
|
||||
tap_action: createFrigateCardCustomAction(
|
||||
'fullscreen',
|
||||
) as FrigateCardCustomAction,
|
||||
style: screenfull.isFullscreen ? this._getEmphasizedStyle() : {},
|
||||
style: options?.inFullscreenMode ? this._getEmphasizedStyle() : {},
|
||||
});
|
||||
}
|
||||
|
||||
buttons.push({
|
||||
icon: expanded ? 'mdi:arrow-collapse-all' : 'mdi:arrow-expand-all',
|
||||
icon: options?.inExpandedMode ? 'mdi:arrow-collapse-all' : 'mdi:arrow-expand-all',
|
||||
...config.menu.buttons.expand,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
title: localize('config.menu.buttons.expand'),
|
||||
tap_action: createFrigateCardCustomAction('expand') as FrigateCardCustomAction,
|
||||
style: expanded ? this._getEmphasizedStyle() : {},
|
||||
style: options?.inExpandedMode ? this._getEmphasizedStyle() : {},
|
||||
});
|
||||
|
||||
if (
|
||||
@@ -417,7 +419,7 @@ export class MenuButtonController {
|
||||
}
|
||||
|
||||
const styledDynamicButtons = this._dynamicMenuButtons.map((button) => ({
|
||||
style: this._getStyleFromActions(config, view, button),
|
||||
style: this._getStyleFromActions(config, view, button, options),
|
||||
...button,
|
||||
}));
|
||||
|
||||
@@ -450,6 +452,7 @@ export class MenuButtonController {
|
||||
config: FrigateCardConfig,
|
||||
view: View,
|
||||
button: MenuButton,
|
||||
options?: MenuButtonControllerOptions,
|
||||
): StyleInfo {
|
||||
for (const actionSet of [
|
||||
button.tap_action,
|
||||
@@ -479,8 +482,7 @@ export class MenuButtonController {
|
||||
(frigateCardAction.frigate_card_action === 'default' &&
|
||||
view.is(config.view.default)) ||
|
||||
(frigateCardAction.frigate_card_action === 'fullscreen' &&
|
||||
screenfull.isEnabled &&
|
||||
screenfull.isFullscreen) ||
|
||||
!!options?.inFullscreenMode) ||
|
||||
(frigateCardAction.frigate_card_action === 'camera_select' &&
|
||||
view.camera === frigateCardAction.camera)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user