Skip to content

Commit d3d1a65

Browse files
committed
fix(webrtc-camera.js): only change shortcuts.innerHTML on difference
1 parent c033e70 commit d3d1a65

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

custom_components/webrtc/www/webrtc-camera.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** Chrome 63+, Safari 11.1+ */
2-
import {VideoRTC} from './video-rtc.js?v=1.9.11';
3-
import {DigitalPTZ} from './digital-ptz.js?v=3.3.0';
2+
import { VideoRTC } from './video-rtc.js?v=1.9.11';
3+
import { DigitalPTZ } from './digital-ptz.js?v=3.3.0';
44

55
class WebRTCCamera extends VideoRTC {
66
/**
@@ -64,7 +64,7 @@ class WebRTCCamera extends VideoRTC {
6464
this.config = Object.assign({
6565
mode: config.mse === false ? 'webrtc' : config.webrtc === false ? 'mse' : this.mode,
6666
media: this.media,
67-
streams: [{url: config.url, entity: config.entity}],
67+
streams: [{ url: config.url, entity: config.entity }],
6868
poster_remote: config.poster && (config.poster.indexOf('://') > 0 || config.poster.charAt(0) === '/'),
6969
}, config);
7070

@@ -97,7 +97,7 @@ class WebRTCCamera extends VideoRTC {
9797
* @return {{url: string}}
9898
*/
9999
static getStubConfig() {
100-
return {'url': ''};
100+
return { 'url': '' };
101101
}
102102

103103
setStatus(mode, status) {
@@ -209,7 +209,7 @@ class WebRTCCamera extends VideoRTC {
209209
}
210210

211211
renderMain() {
212-
const shadow = this.attachShadow({mode: 'open'});
212+
const shadow = this.attachShadow({ mode: 'open' });
213213
shadow.innerHTML = `
214214
<style>
215215
ha-card {
@@ -277,7 +277,7 @@ class WebRTCCamera extends VideoRTC {
277277
this.querySelector('.player'),
278278
this.querySelector('.player .ptz-transform'),
279279
this.video,
280-
Object.assign({}, this.config.digital_ptz, {persist_key: this.config.url})
280+
Object.assign({}, this.config.digital_ptz, { persist_key: this.config.url })
281281
);
282282
}
283283

@@ -414,7 +414,7 @@ class WebRTCCamera extends VideoRTC {
414414
const ptz = this.querySelector('.ptz');
415415
for (const [start, end] of [['touchstart', 'touchend'], ['mousedown', 'mouseup']]) {
416416
ptz.addEventListener(start, startEvt => {
417-
const {className} = startEvt.target;
417+
const { className } = startEvt.target;
418418
startEvt.preventDefault();
419419
handle('start_' + className);
420420
window.addEventListener(end, endEvt => {
@@ -425,7 +425,7 @@ class WebRTCCamera extends VideoRTC {
425425
} else {
426426
handle(className);
427427
}
428-
}, {once: true});
428+
}, { once: true });
429429
});
430430
}
431431
}
@@ -619,7 +619,7 @@ class WebRTCCamera extends VideoRTC {
619619
cancelable: true,
620620
composed: true,
621621
});
622-
event.detail = {entityId: value.more_info};
622+
event.detail = { entityId: value.more_info };
623623
ev.target.dispatchEvent(event);
624624
}
625625
if (value.service !== undefined) {
@@ -629,9 +629,13 @@ class WebRTCCamera extends VideoRTC {
629629
});
630630

631631
this.renderTemplate('shortcuts', () => {
632-
shortcuts.innerHTML = this.config.shortcuts.map((value, index) => `
632+
const innerHTML = this.config.shortcuts.map((value, index) => `
633633
<ha-icon data-index="${index}" icon="${value.icon}" title="${value.name}"></ha-icon>
634634
`).join('');
635+
636+
if (shortcuts.innerHTML !== innerHTML) {
637+
shortcuts.innerHTML = innerHTML;
638+
}
635639
});
636640
}
637641

0 commit comments

Comments
 (0)