Hide buttons that don't work during casting

This commit is contained in:
Dermot Duffy
2022-06-25 09:51:30 -07:00
parent 9905dde925
commit 7fafc46347
+16 -8
View File
@@ -129,9 +129,9 @@ import pkg from '../package.json';
/* eslint no-console: 0 */ /* eslint no-console: 0 */
console.info( console.info(
`%c FRIGATE-HASS-CARD \n` + `%c FRIGATE-HASS-CARD \n` +
`%c ${localize('common.version')} ` + `%c ${localize('common.version')} ` +
`${pkg.version} ` + `${pkg.version} ` +
`${process.env.NODE_ENV === 'development' ? `(${pkg['buildDate']})` : ''}`, `${process.env.NODE_ENV === 'development' ? `(${pkg['buildDate']})` : ''}`,
'color: pink; font-weight: bold; background: black', 'color: pink; font-weight: bold; background: black',
'color: white; font-weight: bold; background: dimgray', 'color: white; font-weight: bold; background: dimgray',
); );
@@ -483,8 +483,8 @@ export class FrigateCard extends LitElement {
} }
if ( if (
this._view?.isViewerView() || !this._isBeingCasted() &&
(this._view?.is('timeline') && !!this._view?.media) (this._view?.isViewerView() || (this._view?.is('timeline') && !!this._view?.media))
) { ) {
buttons.push({ buttons.push({
icon: 'mdi:download', icon: 'mdi:download',
@@ -507,7 +507,7 @@ export class FrigateCard extends LitElement {
}); });
} }
if (screenfull.isEnabled) { if (screenfull.isEnabled && !this._isBeingCasted()) {
buttons.push({ buttons.push({
icon: screenfull.isFullscreen ? 'mdi:fullscreen-exit' : 'mdi:fullscreen', icon: screenfull.isFullscreen ? 'mdi:fullscreen-exit' : 'mdi:fullscreen',
...this._getConfig().menu.buttons.fullscreen, ...this._getConfig().menu.buttons.fullscreen,
@@ -1646,6 +1646,14 @@ export class FrigateCard extends LitElement {
super.disconnectedCallback(); super.disconnectedCallback();
} }
/**
* Determine if the card is currently being casted.
* @returns
*/
protected _isBeingCasted(): boolean {
return !!navigator.userAgent.match(/CrKey\//);
}
/** /**
* Determine if the aspect ratio should be enforced given the current view and * Determine if the aspect ratio should be enforced given the current view and
* context. * context.
@@ -1861,9 +1869,9 @@ export class FrigateCard extends LitElement {
: `` : ``
} }
${!this._message && this._getConfig().elements ${!this._message && this._getConfig().elements
// Elements need to render after the main views so it can render 'on ? // Elements need to render after the main views so it can render 'on
// top'. // top'.
? html` <frigate-card-elements html` <frigate-card-elements
${ref(this._refElements)} ${ref(this._refElements)}
.hass=${this._hass} .hass=${this._hass}
.elements=${this._getConfig().elements} .elements=${this._getConfig().elements}