Only use actionHandler on card.

This commit is contained in:
Dermot Duffy
2021-11-18 10:01:26 -08:00
parent 1ef9609066
commit 2e21456fab
3 changed files with 53 additions and 26 deletions
+10 -17
View File
@@ -677,22 +677,6 @@ export class FrigateCard extends LitElement {
return `${this.config.frigate.url}/events?camera=${this._frigateCameraName}`;
}
/**
* Handle interaction with the card.
*/
protected _interactionHandler(): void {
if (!this.config.view.timeout) {
return;
}
if (this._interactionTimerID) {
window.clearTimeout(this._interactionTimerID);
}
this._interactionTimerID = window.setTimeout(() => {
this._interactionTimerID = null;
this._changeView();
}, this.config.view.timeout * 1000);
}
/**
* Handle an action called on an element.
* @param ev The actionHandler event.
@@ -718,6 +702,16 @@ export class FrigateCard extends LitElement {
) {
handleAction(node, this._hass as HomeAssistant, config, ev.detail.action);
}
if (this.config.view.timeout) {
if (this._interactionTimerID) {
window.clearTimeout(this._interactionTimerID);
}
this._interactionTimerID = window.setTimeout(() => {
this._interactionTimerID = null;
this._changeView();
}, this.config.view.timeout * 1000);
}
}
/**
@@ -962,7 +956,6 @@ export class FrigateCard extends LitElement {
const actions = this._getMergedActions();
return html` <ha-card
@click=${this._interactionHandler}
.actionHandler=${actionHandler({
hasHold: hasAction(actions.hold_action),
hasDoubleClick: hasAction(actions.double_tap_action),