Skip to content

Commit

Permalink
fix how hold time is set on element config update to not create empty…
Browse files Browse the repository at this point in the history
… multi_hold_action
  • Loading branch information
Nerwyn committed Dec 13, 2024
1 parent 9dcd58a commit 68dbfda
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions dist/universal-remote-card.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/classes/base-remote-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class BaseRemoteElement extends LitElement {
}

sendAction(actionType: ActionType, config: IActions = this.config) {
console.log(actionType);
let action;
switch (actionType) {
case 'drag_action':
Expand Down Expand Up @@ -122,7 +121,6 @@ export class BaseRemoteElement extends LitElement {
action = config.tap_action;
break;
}
console.log(action);

if (!action) {
clearTimeout(this.getValueFromHassTimer);
Expand Down
34 changes: 15 additions & 19 deletions src/universal-remote-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,25 +211,21 @@ class UniversalRemoteCard extends LitElement {
}
}

// Set hold time if defined globally or if double tap action is defined
if (
this.config.hold_time ||
updatedElement.double_tap_action ||
updatedElement.multi_double_tap_action
) {
updatedElement.hold_action =
updatedElement.hold_action ?? ({} as IAction);
updatedElement.hold_action.hold_time =
updatedElement.hold_action?.hold_time ??
this.config.hold_time ??
HOLD_TIME;

updatedElement.multi_hold_action =
updatedElement.multi_hold_action ?? ({} as IAction);
updatedElement.multi_hold_action.hold_time =
updatedElement.multi_hold_action?.hold_time ??
this.config.hold_time ??
HOLD_TIME;
// Set hold time if defined globally
if (this.config.hold_time) {
if (updatedElement.hold_action) {
updatedElement.hold_action.hold_time =
updatedElement.hold_action?.hold_time ??
this.config.hold_time ??
HOLD_TIME;
}

if (updatedElement.multi_hold_action) {
updatedElement.multi_hold_action.hold_time =
updatedElement.multi_hold_action?.hold_time ??
this.config.hold_time ??
HOLD_TIME;
}
}

// Set repeat delay if defined globally
Expand Down

0 comments on commit 68dbfda

Please sign in to comment.