Merge pull request #217 from dermotduffy/webrtc-callback

Only register WebRTC callbacks once
This commit is contained in:
Dermot Duffy
2021-11-26 21:25:30 -08:00
committed by GitHub
+6
View File
@@ -225,6 +225,7 @@ export class FrigateCardLiveWebRTC extends LitElement {
protected hass?: HomeAssistant & ExtendedHomeAssistant; protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected _webRTCElement: HTMLElement | null = null; protected _webRTCElement: HTMLElement | null = null;
protected _callbacksAdded = false;
/** /**
* Create the WebRTC element. May throw. * Create the WebRTC element. May throw.
@@ -264,6 +265,10 @@ export class FrigateCardLiveWebRTC extends LitElement {
* Updated lifecycle callback. * Updated lifecycle callback.
*/ */
public updated(): void { public updated(): void {
if (this._callbacksAdded) {
return;
}
// Extract the video component after it has been rendered and generate the // Extract the video component after it has been rendered and generate the
// media load event. // media load event.
this.updateComplete.then(() => { this.updateComplete.then(() => {
@@ -291,6 +296,7 @@ export class FrigateCardLiveWebRTC extends LitElement {
} }
dispatchPauseEvent(this); dispatchPauseEvent(this);
}; };
this._callbacksAdded = true;
} }
}); });
} }