Commit fa98ac0f844dee33c5a6dddd1bc79830bbbd2835
Committed by
GitHub
Merge pull request #5373 from ArtemDzhereleiko/bug-fix/photo-camera-input/empty-datasource
[3.3.2] UI: Fixed Photo Camera input widget has error if entity is empty
Showing
1 changed file
with
10 additions
and
7 deletions
... | ... | @@ -117,6 +117,7 @@ export class PhotoCameraInputWidgetComponent extends PageComponent implements On |
117 | 117 | updatePhoto = false; |
118 | 118 | previewPhoto: SafeUrl; |
119 | 119 | lastPhoto: SafeUrl; |
120 | + datasourceDetected = false; | |
120 | 121 | |
121 | 122 | private static hasGetUserMedia(): boolean { |
122 | 123 | return !!(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia); |
... | ... | @@ -148,14 +149,16 @@ export class PhotoCameraInputWidgetComponent extends PageComponent implements On |
148 | 149 | |
149 | 150 | this.width = this.settings.maxWidth ? this.settings.maxWidth : 640; |
150 | 151 | this.height = this.settings.maxHeight ? this.settings.maxWidth : 480; |
151 | - | |
152 | - if (this.datasource.type === DatasourceType.entity) { | |
153 | - if (this.datasource.entityType && this.datasource.entityId) { | |
154 | - this.isEntityDetected = true; | |
152 | + this.datasourceDetected = this.ctx.datasources?.length !== 0; | |
153 | + if (this.datasourceDetected) { | |
154 | + if (this.datasource.type === DatasourceType.entity) { | |
155 | + if (this.datasource.entityType && this.datasource.entityId) { | |
156 | + this.isEntityDetected = true; | |
157 | + } | |
158 | + } | |
159 | + if (this.datasource.dataKeys.length) { | |
160 | + this.dataKeyDetected = true; | |
155 | 161 | } |
156 | - } | |
157 | - if (this.datasource.dataKeys.length) { | |
158 | - this.dataKeyDetected = true; | |
159 | 162 | } |
160 | 163 | this.detectAvailableDevices(); |
161 | 164 | } | ... | ... |