Don't allow view to propagate upwards from a preloaded camera.
This commit is contained in:
+4
-4
@@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import {
|
import {
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
LitElement,
|
LitElement,
|
||||||
@@ -114,8 +113,9 @@ console.info(
|
|||||||
'color: white; font-weight: bold; background: dimgray',
|
'color: white; font-weight: bold; background: dimgray',
|
||||||
);
|
);
|
||||||
|
|
||||||
// This puts your card into the UI card picker dialog
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(window as any).customCards = (window as any).customCards || [];
|
(window as any).customCards = (window as any).customCards || [];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(window as any).customCards.push({
|
(window as any).customCards.push({
|
||||||
type: 'frigate-card',
|
type: 'frigate-card',
|
||||||
name: localize('common.frigate_card'),
|
name: localize('common.frigate_card'),
|
||||||
@@ -508,7 +508,7 @@ export class FrigateCard extends LitElement {
|
|||||||
return match.groups['camera'];
|
return match.groups['camera'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
// Pass.
|
// Pass.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1225,7 +1225,7 @@ export class FrigateCard extends LitElement {
|
|||||||
.conditionState=${this._conditionState}
|
.conditionState=${this._conditionState}
|
||||||
.liveOverrides=${getOverridesByKey(this._getConfig().overrides, 'live')}
|
.liveOverrides=${getOverridesByKey(this._getConfig().overrides, 'live')}
|
||||||
.cameras=${this._cameras}
|
.cameras=${this._cameras}
|
||||||
.preload=${this._getConfig().live.preload && !this._view.is('live')}
|
.preloaded=${this._getConfig().live.preload && !this._view.is('live')}
|
||||||
class="${classMap(liveClasses)}"
|
class="${classMap(liveClasses)}"
|
||||||
>
|
>
|
||||||
</frigate-card-live>
|
</frigate-card-live>
|
||||||
|
|||||||
+18
-13
@@ -1,8 +1,3 @@
|
|||||||
// TODO autodetect live provider from cameras configuration, or allow explicit setting.
|
|
||||||
// TODO config-mgmt move for live provider
|
|
||||||
// TODO unroll webrtc object in camera config for parity with live provider?
|
|
||||||
// TODO order of cameras may not be being preserved.
|
|
||||||
// TODO the back-button issue raised on the PR
|
|
||||||
// TODO verify README links worked correctly (e.g. basic cameras configuration)
|
// TODO verify README links worked correctly (e.g. basic cameras configuration)
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -86,17 +81,17 @@ export class FrigateCardLive extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected conditionState?: ConditionState;
|
protected conditionState?: ConditionState;
|
||||||
|
|
||||||
set preload(preload: boolean) {
|
set preloaded(preloaded: boolean) {
|
||||||
this._preload = preload;
|
this._preloaded = preloaded;
|
||||||
|
|
||||||
if (!preload && this._savedMediaShowInfo) {
|
if (!preloaded && this._savedMediaShowInfo) {
|
||||||
dispatchExistingMediaShowInfoAsEvent(this, this._savedMediaShowInfo);
|
dispatchExistingMediaShowInfoAsEvent(this, this._savedMediaShowInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether or not the live view is currently being preloaded.
|
// Whether or not the live view is currently being preloaded.
|
||||||
@state()
|
@state()
|
||||||
protected _preload?: boolean;
|
protected _preloaded?: boolean;
|
||||||
|
|
||||||
// MediaShowInfo object from the underlying live object. In the case of
|
// MediaShowInfo object from the underlying live object. In the case of
|
||||||
// pre-loading it may be propagated upwards later.
|
// pre-loading it may be propagated upwards later.
|
||||||
@@ -108,7 +103,7 @@ export class FrigateCardLive extends LitElement {
|
|||||||
*/
|
*/
|
||||||
protected _mediaShowHandler(e: CustomEvent<MediaShowInfo>): void {
|
protected _mediaShowHandler(e: CustomEvent<MediaShowInfo>): void {
|
||||||
this._savedMediaShowInfo = e.detail;
|
this._savedMediaShowInfo = e.detail;
|
||||||
if (this._preload) {
|
if (this._preloaded) {
|
||||||
// If live is being pre-loaded, don't let the event propogate upwards yet
|
// If live is being pre-loaded, don't let the event propogate upwards yet
|
||||||
// as the media is not really being shown.
|
// as the media is not really being shown.
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -195,7 +190,7 @@ export class FrigateCardLive extends LitElement {
|
|||||||
.view=${this.view}
|
.view=${this.view}
|
||||||
.cameras=${this.cameras}
|
.cameras=${this.cameras}
|
||||||
.liveConfig=${this.liveConfig}
|
.liveConfig=${this.liveConfig}
|
||||||
.preload=${this._preload}
|
.preloaded=${this._preloaded}
|
||||||
.conditionState=${this.conditionState}
|
.conditionState=${this.conditionState}
|
||||||
.liveOverrides=${this.liveOverrides}
|
.liveOverrides=${this.liveOverrides}
|
||||||
@frigate-card:media-show=${this._mediaShowHandler}
|
@frigate-card:media-show=${this._mediaShowHandler}
|
||||||
@@ -204,6 +199,16 @@ export class FrigateCardLive extends LitElement {
|
|||||||
// re-fetched (which is necessary because the camera has changed).
|
// re-fetched (which is necessary because the camera has changed).
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}}
|
}}
|
||||||
|
@frigate-card:change-view=${(ev: CustomEvent) => {
|
||||||
|
if (this._preloaded) {
|
||||||
|
// Don't allow change-view events to propagate upwards if the card
|
||||||
|
// is only preloaded rather than being live displayed. These events
|
||||||
|
// could be triggered if the camera is switched and the carousel
|
||||||
|
// moves to focus on that camera -- as the card isn't actually being
|
||||||
|
// displayed, do not allow the view to actually be updated.
|
||||||
|
ev.stopPropagation();
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
</frigate-card-live-carousel>
|
</frigate-card-live-carousel>
|
||||||
${config.controls.thumbnails.mode === 'below' ? this.renderThumbnails(config) : ''}
|
${config.controls.thumbnails.mode === 'below' ? this.renderThumbnails(config) : ''}
|
||||||
@@ -236,7 +241,7 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
|
|||||||
protected liveOverrides?: LiveOverrides;
|
protected liveOverrides?: LiveOverrides;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected preload?: boolean;
|
protected preloaded?: boolean;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected conditionState?: ConditionState;
|
protected conditionState?: ConditionState;
|
||||||
@@ -252,7 +257,7 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
|
|||||||
if (
|
if (
|
||||||
changedProperties.has('cameras') ||
|
changedProperties.has('cameras') ||
|
||||||
changedProperties.has('liveConfig') ||
|
changedProperties.has('liveConfig') ||
|
||||||
changedProperties.has('preload')
|
changedProperties.has('preloaded')
|
||||||
) {
|
) {
|
||||||
// All of these properties may fundamentally change the contents/size of
|
// All of these properties may fundamentally change the contents/size of
|
||||||
// the DOM, and the carousel should be reset when they change.
|
// the DOM, and the carousel should be reset when they change.
|
||||||
|
|||||||
Reference in New Issue
Block a user