@chat21/chat21-web-widget 5.0.97 → 5.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@
6
6
  ### **Copyrigth**:
7
7
  *Tiledesk SRL*
8
8
 
9
+ # 5.0.99
10
+
11
+ # 5.0.99-rc1
12
+ - **bug-fixed**: audio duration not showed in mobile browser
13
+
14
+ # 5.0.98
15
+ - **bug-fixed**: meta info not rendered correctly
16
+
9
17
  # 5.0.97
10
18
 
11
19
  # 5.0.96
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.0.97",
4
+ "version": "5.0.99",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -67,7 +67,7 @@ export class HomeConversationsComponent implements OnInit, OnDestroy {
67
67
  availableAgents: Array<UserAgent> = [];
68
68
  // ========= end:: variabili del componente ======== //
69
69
 
70
- waitingTime: Number;
70
+ waitingTime: number;
71
71
  langService: HumanizeDurationLanguage = new HumanizeDurationLanguage();
72
72
  humanizer: HumanizeDuration;
73
73
  humanWaitingTime: string;
@@ -1,5 +1,7 @@
1
1
  import { Component, ElementRef, AfterViewInit, Input, ViewChild } from '@angular/core';
2
2
  import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
3
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
4
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
3
5
  import { convertColorToRGBA } from 'src/chat21-core/utils/utils';
4
6
 
5
7
  @Component({
@@ -26,13 +28,13 @@ export class AudioComponent implements AfterViewInit {
26
28
  currentTime: number = 0;
27
29
  isPlaying: boolean = false;
28
30
 
31
+ private logger: LoggerService = LoggerInstance.getInstance();
29
32
  constructor(
30
33
  private sanitizer: DomSanitizer,
31
34
  private elementRef: ElementRef
32
35
  ) {}
33
36
 
34
37
  ngAfterViewInit() {
35
- console.log('stylesssss', this.stylesMap)
36
38
  if (this.audioBlob) {
37
39
  this.rawAudioUrl = URL.createObjectURL(this.audioBlob);
38
40
  this.audioUrl = this.sanitizer.bypassSecurityTrustUrl(this.rawAudioUrl);
@@ -136,21 +138,33 @@ export class AudioComponent implements AfterViewInit {
136
138
  return `${minutes}:${sec < 10 ? '0' + sec : sec}`;
137
139
  }
138
140
 
139
- getAudioDuration() {
140
- const audio = new Audio();
141
- audio.src = this.rawAudioUrl!;
142
- audio.addEventListener('loadedmetadata', () => {
143
- if (audio.duration === Infinity) {
144
- audio.currentTime = Number.MAX_SAFE_INTEGER;
145
- audio.ontimeupdate = () => {
146
- audio.ontimeupdate = null;
147
- audio.currentTime = 0;
148
- this.audioDuration = audio.duration;
149
- };
150
- } else {
151
- this.audioDuration = audio.duration;
152
- }
153
- });
141
+ async getAudioDuration() {
142
+ // const audio = new Audio();
143
+ // audio.src = this.rawAudioUrl!;
144
+ // audio.addEventListener('loadedmetadata', () => {
145
+ // if (audio.duration === Infinity) {
146
+ // audio.currentTime = Number.MAX_SAFE_INTEGER;
147
+ // audio.ontimeupdate = () => {
148
+ // audio.ontimeupdate = null;
149
+ // audio.currentTime = 0;
150
+ // this.audioDuration = audio.duration;
151
+ // };
152
+ // } else {
153
+ // this.audioDuration = audio.duration;
154
+ // }
155
+ // });
156
+
157
+ const response = await fetch(this.rawAudioUrl!);
158
+ this.logger.debug('getAudioDuration: response ---> ', response)
159
+ const arrayBuffer = await response.arrayBuffer();
160
+ this.logger.debug('getAudioDuration: arrayBuffer ---> ', arrayBuffer)
161
+ const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
162
+ this.logger.debug('getAudioDuration: audioContext ---> ', audioContext)
163
+ const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
164
+ this.logger.debug('getAudioDuration: audioBuffer ---> ', audioBuffer)
165
+ this.audioDuration = audioBuffer.duration;
166
+ this.logger.debug('getAudioDuration: audioDuration ---> ', this.audioDuration)
167
+
154
168
  }
155
169
 
156
170
  extractFirstColor(gradient: string): string | null {
@@ -613,7 +613,7 @@
613
613
  var brandJson = JSON.parse(xhr.response)
614
614
  if(brandJson){
615
615
  /** TITLE AND FAVICON **/
616
- brandJson['WIDGET'].META_TITLE? document.body.title = brandJson['WIDGET'].META_TITLE : null;
616
+ brandJson['WIDGET'].META_TITLE? document.title = brandJson['WIDGET'].META_TITLE : null;
617
617
  brandJson['WIDGET'].FAVICON_URL? document.querySelector("link[rel~='icon']").setAttribute('href', brandJson['WIDGET'].FAVICON_URL) : null;
618
618
  /** FOOTER-LOGO **/
619
619
  brandJson['COMMON'].COMPANY_LOGO? document.getElementById('footer-logo').src = brandJson['COMMON'].COMPANY_LOGO : null;
@@ -624,6 +624,13 @@
624
624
  brandJson['COMMON'].BRAND_PRIMARY_COLOR? document.body.style.setProperty('--base-company-logo', brandJson['COMMON'].BRAND_PRIMARY_COLOR): null;
625
625
  /** IFRAME TITLE**/
626
626
  brandJson['COMMON'].COMPANY_NAME? document.getElementById('tiledeskiframe').title = brandJson['COMMON'].COMPANY_NAME + ' Widget' : null;
627
+ /** META sharing ELEMENTS */
628
+ if(brandJson['WIDGET'].META_SHARE_INFO && Object.keys(brandJson['WIDGET'].META_SHARE_INFO).length > 0){
629
+ Object.keys(brandJson['WIDGET'].META_SHARE_INFO).forEach(key => {
630
+ var meta = document.querySelector("meta[property^='og:"+key.toLowerCase()+"']");
631
+ meta.setAttribute('content', brandJson['WIDGET'].META_SHARE_INFO[key])
632
+ })
633
+ }
627
634
  }
628
635
  }
629
636
 
@@ -719,7 +719,7 @@
719
719
  var brandJson = JSON.parse(xhr.response)
720
720
  if(brandJson){
721
721
  /** TITLE AND FAVICON **/
722
- brandJson['WIDGET'].META_TITLE? document.body.title = brandJson['WIDGET'].META_TITLE : null;
722
+ brandJson['WIDGET'].META_TITLE? document.title = brandJson['WIDGET'].META_TITLE : null;
723
723
  brandJson['WIDGET'].FAVICON_URL? document.querySelector("link[rel~='icon']").setAttribute('href', brandJson['WIDGET'].FAVICON_URL) : null;
724
724
  /** FOOTER-LOGO **/
725
725
  brandJson['COMMON'].COMPANY_LOGO? document.getElementById('footer-logo').src = brandJson['COMMON'].COMPANY_LOGO : null;
@@ -737,6 +737,13 @@
737
737
  }
738
738
  /** IFRAME TITLE**/
739
739
  brandJson['COMMON'].COMPANY_LOGO? document.getElementById('tiledeskiframe').title = brandJson['COMMON'].COMPANY_NAME + ' Widget' : null;
740
+ /** META sharing ELEMENTS */
741
+ if(brandJson['WIDGET'].META_SHARE_INFO && Object.keys(brandJson['WIDGET'].META_SHARE_INFO).length > 0){
742
+ Object.keys(brandJson['WIDGET'].META_SHARE_INFO).forEach(key => {
743
+ var meta = document.querySelector("meta[property^='og:"+key.toLowerCase()+"']");
744
+ meta.setAttribute('content', brandJson['WIDGET'].META_SHARE_INFO[key])
745
+ })
746
+ }
740
747
  }
741
748
  }
742
749
  }
@@ -6,7 +6,7 @@
6
6
  <meta charset="utf-8">
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8
8
 
9
- <title>Widget test page </title>
9
+ <title>Widget test page</title>
10
10
  <style>
11
11
 
12
12
  @-moz-keyframes blink {0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} /* Firefox */
@@ -295,7 +295,10 @@
295
295
  window.Tiledesk('onBeforeInit', function(event_data) {
296
296
  console.log("onBeforeInit Tiledesk FN", event_data);
297
297
 
298
- var brandSrc = event_data.detail.appConfigs.brandSrc? getBrandResources(event_data.detail.appConfigs.brandSrc) : null;
298
+ if(event_data.detail.appConfigs.brandSrc){
299
+ getBrandResources(event_data.detail.appConfigs.brandSrc)
300
+ }
301
+ // var brandSrc = event_data.detail.appConfigs.brandSrc? : null;
299
302
 
300
303
  setTimeout(() => {
301
304
  if(event_data && event_data.detail && event_data.detail.appConfigs){
@@ -408,7 +411,7 @@
408
411
  var brandJson = JSON.parse(xhr.response)
409
412
  if(brandJson){
410
413
  /** TITLE AND FAVICON **/
411
- brandJson['WIDGET'].META_TITLE? document.body.title = brandJson['WIDGET'].META_TITLE : null;
414
+ brandJson['WIDGET'].META_TITLE? document.title = brandJson['WIDGET'].META_TITLE : null;
412
415
  brandJson['WIDGET'].FAVICON_URL? document.querySelector("link[rel~='icon']").setAttribute('href', brandJson['WIDGET'].FAVICON_URL) : null;
413
416
  /** FOOTER-LOGO **/
414
417
  brandJson['COMMON'].COMPANY_LOGO? document.getElementById('footer-logo').src = brandJson['COMMON'].COMPANY_LOGO : null;
@@ -421,6 +424,13 @@
421
424
  brandJson['COMMON'].DOCS? null: document.getElementById('share').style.display = 'none'
422
425
  /** IFRAME TITLE**/
423
426
  brandJson['COMMON'].COMPANY_LOGO? document.getElementById('tiledeskiframe').title = brandJson['COMMON'].COMPANY_NAME + ' Widget' : null;
427
+ /** META sharing ELEMENTS */
428
+ if(brandJson['WIDGET'].META_SHARE_INFO && Object.keys(brandJson['WIDGET'].META_SHARE_INFO).length > 0){
429
+ Object.keys(brandJson['WIDGET'].META_SHARE_INFO).forEach(key => {
430
+ var meta = document.querySelector("meta[property^='og:"+key.toLowerCase()+"']");
431
+ meta.setAttribute('content', brandJson['WIDGET'].META_SHARE_INFO[key])
432
+ })
433
+ }
424
434
  }
425
435
 
426
436
  }