From bede6f2c5768d795d257a2ac14ae488651a46118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Mon, 12 Jul 2021 13:57:27 +0200 Subject: [PATCH] no message --- dist/plex-meets-homeassistant.js | 21 ++++++++++++--------- src/editor.ts | 3 +++ src/plex-meets-homeassistant.ts | 18 +++++++++--------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 99dbd0f..0111357 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19480,6 +19480,9 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { 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; this.config.sort = `${this.sort.value}:${this.sortOrder.value}`; @@ -21711,6 +21714,15 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; this.setConfig = (config) => { this.plexProtocol = 'http'; + if (!config.ip) { + throw new Error('You need to define a Plex IP Address'); + } + if (!config.token) { + throw new Error('You need to define a Plex Token'); + } + if (!config.libraryName) { + throw new Error('You need to define a libraryName'); + } if (!config.entity || config.entity.length === 0) { throw new Error('You need to define at least one entity'); } @@ -21730,15 +21742,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { else if (!lodash.isString(config.entity) && !lodash.isArray(config.entity)) { throw new Error('You need to define at least one supported entity'); } - if (!config.token) { - throw new Error('You need to define a token'); - } - if (!config.ip) { - throw new Error('You need to define a ip'); - } - if (!config.libraryName) { - throw new Error('You need to define a libraryName'); - } this.config = config; if (config.protocol) { this.plexProtocol = config.protocol; diff --git a/src/editor.ts b/src/editor.ts index 7edfbdf..af7420f 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -71,6 +71,9 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { 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; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 9bb97d9..ea35df8 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -1495,6 +1495,15 @@ class PlexMeetsHomeAssistant extends HTMLElement { setConfig = (config: any): void => { this.plexProtocol = 'http'; + if (!config.ip) { + throw new Error('You need to define a Plex IP Address'); + } + if (!config.token) { + throw new Error('You need to define a Plex Token'); + } + if (!config.libraryName) { + throw new Error('You need to define a libraryName'); + } if (!config.entity || config.entity.length === 0) { throw new Error('You need to define at least one entity'); } @@ -1513,15 +1522,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { } else if (!_.isString(config.entity) && !_.isArray(config.entity)) { throw new Error('You need to define at least one supported entity'); } - if (!config.token) { - throw new Error('You need to define a token'); - } - if (!config.ip) { - throw new Error('You need to define a ip'); - } - if (!config.libraryName) { - throw new Error('You need to define a libraryName'); - } this.config = config; if (config.protocol) { this.plexProtocol = config.protocol;