From d473a5b85e4d5e0b6d0992dce1b7eb2d7cfc9655 Mon Sep 17 00:00:00 2001 From: ArtemDzhereleiko Date: Wed, 13 Oct 2021 16:09:36 +0300 Subject: [PATCH] Fixed Photo Camera input error if entity is empty --- .../widget/lib/photo-camera-input.component.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/photo-camera-input.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/photo-camera-input.component.ts index c791b88589..b752d73b67 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/photo-camera-input.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/photo-camera-input.component.ts @@ -117,6 +117,7 @@ export class PhotoCameraInputWidgetComponent extends PageComponent implements On updatePhoto = false; previewPhoto: SafeUrl; lastPhoto: SafeUrl; + datasourceDetected = false; private static hasGetUserMedia(): boolean { return !!(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia); @@ -148,14 +149,16 @@ export class PhotoCameraInputWidgetComponent extends PageComponent implements On this.width = this.settings.maxWidth ? this.settings.maxWidth : 640; this.height = this.settings.maxHeight ? this.settings.maxWidth : 480; - - if (this.datasource.type === DatasourceType.entity) { - if (this.datasource.entityType && this.datasource.entityId) { - this.isEntityDetected = true; + this.datasourceDetected = this.ctx.datasources?.length !== 0; + if (this.datasourceDetected) { + if (this.datasource.type === DatasourceType.entity) { + if (this.datasource.entityType && this.datasource.entityId) { + this.isEntityDetected = true; + } + } + if (this.datasource.dataKeys.length) { + this.dataKeyDetected = true; } - } - if (this.datasource.dataKeys.length) { - this.dataKeyDetected = true; } this.detectAvailableDevices(); }