From f2a870cc50f843899717e7450a10c6707dbf15c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Mon, 12 Jul 2021 17:19:05 +0200 Subject: [PATCH] no message --- dist/plex-meets-homeassistant.js | 122 ++++++++++++++++--------------- src/editor.ts | 113 ++++++++++++++-------------- 2 files changed, 122 insertions(+), 113 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index c9cf90b..a8c0327 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19468,6 +19468,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.sections = []; this.entitiesRegistry = false; this.plexValidSection = document.createElement('div'); + this.loaded = false; this.fireEvent = (node, type, detail, options = {}) => { // eslint-disable-next-line no-param-reassign detail = detail === null || detail === undefined ? {} : detail; @@ -19481,69 +19482,71 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { return event; }; this.valueUpdated = () => { - const originalConfig = lodash.clone(this.config); - this.config.protocol = this.protocol.value; - this.config.ip = this.ip.value; - this.config.token = this.token.value; - this.config.port = this.port.value; - if (!this.config.entity) { - this.config.entity = []; - } - if (!lodash.isEmpty(this.libraryName.value)) { - this.config.libraryName = this.libraryName.value; - let sortOrderValue = ''; - if (lodash.isEqual(this.sortOrder.value, 'Ascending')) { - sortOrderValue = 'asc'; - } - else if (lodash.isEqual(this.sortOrder.value, 'Descending')) { - sortOrderValue = 'desc'; - } - if (!lodash.isEmpty(sortOrderValue) && !lodash.isEmpty(this.sort.value)) { - this.config.sort = `${this.sort.value}:${sortOrderValue}`; - } - else { - this.config.sort = ``; - } - if (lodash.isEmpty(this.maxCount.value)) { - this.config.maxCount = ''; - } - else { - this.config.maxCount = this.maxCount.value; - } - if (!lodash.isEmpty(this.entities)) { + if (this.loaded) { + const originalConfig = lodash.clone(this.config); + this.config.protocol = this.protocol.value; + this.config.ip = this.ip.value; + this.config.token = this.token.value; + this.config.port = this.port.value; + if (!this.config.entity) { this.config.entity = []; - lodash.forEach(this.entities, entity => { - if (!lodash.isEmpty(entity.value) && !lodash.includes(this.config.entity, entity.value)) { - this.config.entity.push(entity.value); - } - }); - } - if (lodash.isEqual(this.playTrailer.value, 'Yes')) { - this.config.playTrailer = true; - } - else if (lodash.isEqual(this.playTrailer.value, 'No')) { - this.config.playTrailer = false; - } - else if (lodash.isEqual(this.playTrailer.value, 'Muted')) { - this.config.playTrailer = 'muted'; } - if (lodash.isEqual(this.showExtras.value, 'Yes')) { - this.config.showExtras = true; - } - else if (lodash.isEqual(this.showExtras.value, 'No')) { - this.config.showExtras = false; - } - if (lodash.isEqual(this.showSearch.value, 'Yes')) { - this.config.showSearch = true; + if (!lodash.isEmpty(this.libraryName.value)) { + this.config.libraryName = this.libraryName.value; + let sortOrderValue = ''; + if (lodash.isEqual(this.sortOrder.value, 'Ascending')) { + sortOrderValue = 'asc'; + } + else if (lodash.isEqual(this.sortOrder.value, 'Descending')) { + sortOrderValue = 'desc'; + } + if (!lodash.isEmpty(sortOrderValue) && !lodash.isEmpty(this.sort.value)) { + this.config.sort = `${this.sort.value}:${sortOrderValue}`; + } + else { + this.config.sort = ``; + } + if (lodash.isEmpty(this.maxCount.value)) { + this.config.maxCount = ''; + } + else { + this.config.maxCount = this.maxCount.value; + } + if (!lodash.isEmpty(this.entities)) { + this.config.entity = []; + lodash.forEach(this.entities, entity => { + if (!lodash.isEmpty(entity.value) && !lodash.includes(this.config.entity, entity.value)) { + this.config.entity.push(entity.value); + } + }); + } + if (lodash.isEqual(this.playTrailer.value, 'Yes')) { + this.config.playTrailer = true; + } + else if (lodash.isEqual(this.playTrailer.value, 'No')) { + this.config.playTrailer = false; + } + else if (lodash.isEqual(this.playTrailer.value, 'Muted')) { + this.config.playTrailer = 'muted'; + } + if (lodash.isEqual(this.showExtras.value, 'Yes')) { + this.config.showExtras = true; + } + else if (lodash.isEqual(this.showExtras.value, 'No')) { + this.config.showExtras = false; + } + if (lodash.isEqual(this.showSearch.value, 'Yes')) { + this.config.showSearch = true; + } + else if (lodash.isEqual(this.showSearch.value, 'No')) { + this.config.showSearch = false; + } + this.config.runBefore = this.runBefore.value; + this.config.runAfter = this.runAfter.value; } - else if (lodash.isEqual(this.showSearch.value, 'No')) { - this.config.showSearch = false; + if (!lodash.isEqual(this.config, originalConfig)) { + this.fireEvent(this, 'config-changed', { config: this.config }); } - this.config.runBefore = this.runBefore.value; - this.config.runAfter = this.runAfter.value; - } - if (!lodash.isEqual(this.config, originalConfig)) { - this.fireEvent(this, 'config-changed', { config: this.config }); } }; this.render = async () => { @@ -19910,6 +19913,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { } this.plexValidSection.style.display = 'block'; } + this.loaded = true; this.content.appendChild(this.plexValidSection); }; this.setConfig = (config) => { diff --git a/src/editor.ts b/src/editor.ts index 24b5035..c0cff15 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -60,6 +60,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { plexValidSection = document.createElement('div'); + loaded = false; + fireEvent = ( node: HTMLElement, type: string, @@ -79,65 +81,67 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { }; valueUpdated = (): void => { - const originalConfig = _.clone(this.config); - this.config.protocol = this.protocol.value; - this.config.ip = this.ip.value; - this.config.token = this.token.value; - this.config.port = this.port.value; - if (!this.config.entity) { - this.config.entity = []; - } - if (!_.isEmpty(this.libraryName.value)) { - this.config.libraryName = this.libraryName.value; - - let sortOrderValue = ''; - if (_.isEqual(this.sortOrder.value, 'Ascending')) { - sortOrderValue = 'asc'; - } else if (_.isEqual(this.sortOrder.value, 'Descending')) { - sortOrderValue = 'desc'; - } - if (!_.isEmpty(sortOrderValue) && !_.isEmpty(this.sort.value)) { - this.config.sort = `${this.sort.value}:${sortOrderValue}`; - } else { - this.config.sort = ``; + if (this.loaded) { + const originalConfig = _.clone(this.config); + this.config.protocol = this.protocol.value; + this.config.ip = this.ip.value; + this.config.token = this.token.value; + this.config.port = this.port.value; + if (!this.config.entity) { + this.config.entity = []; } + if (!_.isEmpty(this.libraryName.value)) { + this.config.libraryName = this.libraryName.value; + + let sortOrderValue = ''; + if (_.isEqual(this.sortOrder.value, 'Ascending')) { + sortOrderValue = 'asc'; + } else if (_.isEqual(this.sortOrder.value, 'Descending')) { + sortOrderValue = 'desc'; + } + if (!_.isEmpty(sortOrderValue) && !_.isEmpty(this.sort.value)) { + this.config.sort = `${this.sort.value}:${sortOrderValue}`; + } else { + this.config.sort = ``; + } - if (_.isEmpty(this.maxCount.value)) { - this.config.maxCount = ''; - } else { - this.config.maxCount = this.maxCount.value; - } + if (_.isEmpty(this.maxCount.value)) { + this.config.maxCount = ''; + } else { + this.config.maxCount = this.maxCount.value; + } - if (!_.isEmpty(this.entities)) { - this.config.entity = []; - _.forEach(this.entities, entity => { - if (!_.isEmpty(entity.value) && !_.includes(this.config.entity, entity.value)) { - this.config.entity.push(entity.value); - } - }); - } - if (_.isEqual(this.playTrailer.value, 'Yes')) { - this.config.playTrailer = true; - } else if (_.isEqual(this.playTrailer.value, 'No')) { - this.config.playTrailer = false; - } else if (_.isEqual(this.playTrailer.value, 'Muted')) { - this.config.playTrailer = 'muted'; - } - if (_.isEqual(this.showExtras.value, 'Yes')) { - this.config.showExtras = true; - } else if (_.isEqual(this.showExtras.value, 'No')) { - this.config.showExtras = false; + if (!_.isEmpty(this.entities)) { + this.config.entity = []; + _.forEach(this.entities, entity => { + if (!_.isEmpty(entity.value) && !_.includes(this.config.entity, entity.value)) { + this.config.entity.push(entity.value); + } + }); + } + if (_.isEqual(this.playTrailer.value, 'Yes')) { + this.config.playTrailer = true; + } else if (_.isEqual(this.playTrailer.value, 'No')) { + this.config.playTrailer = false; + } else if (_.isEqual(this.playTrailer.value, 'Muted')) { + this.config.playTrailer = 'muted'; + } + if (_.isEqual(this.showExtras.value, 'Yes')) { + this.config.showExtras = true; + } else if (_.isEqual(this.showExtras.value, 'No')) { + this.config.showExtras = false; + } + if (_.isEqual(this.showSearch.value, 'Yes')) { + this.config.showSearch = true; + } else if (_.isEqual(this.showSearch.value, 'No')) { + this.config.showSearch = false; + } + this.config.runBefore = this.runBefore.value; + this.config.runAfter = this.runAfter.value; } - if (_.isEqual(this.showSearch.value, 'Yes')) { - this.config.showSearch = true; - } else if (_.isEqual(this.showSearch.value, 'No')) { - this.config.showSearch = false; + if (!_.isEqual(this.config, originalConfig)) { + this.fireEvent(this, 'config-changed', { config: this.config }); } - this.config.runBefore = this.runBefore.value; - this.config.runAfter = this.runAfter.value; - } - if (!_.isEqual(this.config, originalConfig)) { - this.fireEvent(this, 'config-changed', { config: this.config }); } }; @@ -522,6 +526,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.plexValidSection.style.display = 'block'; } + this.loaded = true; this.content.appendChild(this.plexValidSection); };