@chat21/chat21-web-widget 5.1.20 → 5.1.24-rc1

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.
Files changed (35) hide show
  1. package/.github/workflows/docker-community-push-latest.yml +23 -13
  2. package/.github/workflows/docker-image-tag-community-tag-push.yml +22 -12
  3. package/CHANGELOG.md +64 -2
  4. package/Dockerfile +4 -5
  5. package/angular.json +2 -1
  6. package/deploy_amazon_beta.sh +17 -7
  7. package/package.json +1 -1
  8. package/src/app/app.component.html +8 -1
  9. package/src/app/app.component.scss +59 -0
  10. package/src/app/app.component.ts +92 -34
  11. package/src/app/component/conversation-detail/conversation/conversation.component.ts +18 -4
  12. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +25 -0
  13. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +2 -1
  14. package/src/app/component/home-conversations/home-conversations.component.html +16 -6
  15. package/src/app/component/home-conversations/home-conversations.component.ts +29 -0
  16. package/src/app/component/launcher-button/launcher-button.component.html +1 -1
  17. package/src/app/component/launcher-button/launcher-button.component.ts +3 -2
  18. package/src/app/component/list-conversations/list-conversations.component.html +8 -3
  19. package/src/app/component/list-conversations/list-conversations.component.ts +29 -0
  20. package/src/app/pipe/marked.pipe.ts +27 -154
  21. package/src/app/providers/global-settings.service.ts +1 -1
  22. package/src/app/providers/translator.service.ts +2 -0
  23. package/src/app/utils/globals.ts +1 -1
  24. package/src/assets/i18n/en.json +1 -0
  25. package/src/assets/i18n/es.json +1 -0
  26. package/src/assets/i18n/fr.json +1 -0
  27. package/src/assets/i18n/it.json +1 -0
  28. package/src/chat21-core/providers/abstract/upload.service.ts +5 -1
  29. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +141 -12
  30. package/src/chat21-core/providers/native/native-image-repo.ts +1 -1
  31. package/src/chat21-core/providers/native/native-upload-service.ts +143 -46
  32. package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +1 -1
  33. package/src/chat21-core/utils/utils.ts +5 -2
  34. package/src/iframe-style.css +5 -5
  35. package/deploy_amazon_prod.sh +0 -41
@@ -1,10 +1,10 @@
1
1
  name: Docker Image Community latest CI
2
2
 
3
- on:
4
- push:
3
+ on:
4
+ push:
5
5
  branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
8
 
9
9
  jobs:
10
10
  push_to_registry:
@@ -12,12 +12,22 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
 
14
14
  steps:
15
- - uses: actions/checkout@v2
16
- name: Check out the repo
17
- - uses: docker/build-push-action@v1
18
- with:
19
- username: ${{ secrets.DOCKERHUB_USERNAME }}
20
- password: ${{ secrets.DOCKERHUB_TOKEN }}
21
- repository: chat21/chat21-web-widget
22
- push: true
23
- tags: latest
15
+ - name: Check out the repo
16
+ uses: actions/checkout@v2
17
+
18
+ - name: Set up Docker Buildx
19
+ uses: docker/setup-buildx-action@v2
20
+
21
+ - name: Log in to Docker Hub
22
+ uses: docker/login-action@v2
23
+ with:
24
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
25
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
26
+
27
+ - name: Build and push multiarch Docker image
28
+ uses: docker/build-push-action@v3
29
+ with:
30
+ context: .
31
+ push: true
32
+ platforms: linux/amd64,linux/arm64
33
+ tags: chat21/chat21-web-widget:latest
@@ -3,20 +3,30 @@ name: Publish Docker Community image tags
3
3
  on:
4
4
  push:
5
5
  tags:
6
- - '**' # Push events to every tag including hierarchical tags like
7
- jobs:
6
+ - '**' # Trigger su qualsiasi tag
8
7
 
8
+ jobs:
9
9
  push_to_registry:
10
10
  name: Push Docker image to Docker Hub
11
11
  runs-on: ubuntu-latest
12
+
12
13
  steps:
13
- - name: Check out the repo
14
- uses: actions/checkout@v2
15
- - name: Push to Docker Hub
16
- uses: docker/build-push-action@v1
17
- with:
18
- username: ${{ secrets.DOCKERHUB_USERNAME }}
19
- password: ${{ secrets.DOCKERHUB_TOKEN }}
20
- repository: chat21/chat21-web-widget
21
- push: true
22
- tag_with_ref: true
14
+ - name: Check out the repo
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Docker Buildx
18
+ uses: docker/setup-buildx-action@v2
19
+
20
+ - name: Log in to Docker Hub
21
+ uses: docker/login-action@v2
22
+ with:
23
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
24
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
25
+
26
+ - name: Build and push multiarch Docker image
27
+ uses: docker/build-push-action@v3
28
+ with:
29
+ context: .
30
+ push: true
31
+ platforms: linux/amd64,linux/arm64
32
+ tags: chat21/chat21-web-widget:${{ github.ref_name }}
package/CHANGELOG.md CHANGED
@@ -6,10 +6,23 @@
6
6
  ### **Copyrigth**:
7
7
  *Tiledesk SRL*
8
8
 
9
- # 5.1.20
9
+ # 5.1.24-rc1
10
+ - **security**: hardened Markdown link rendering by blocking dangerous protocols (e.g. `javascript:`, `data:`, `vbscript:`) and preventing unsafe links from being rendered as anchors
11
+ - **changed**: refactored `MarkedPipe` to simplify Markdown parsing, improve link rendering via a custom `marked` renderer, and streamline newline handling (`\\n` → `\n`)
12
+
13
+ # 5.1.20-rc3
14
+ - **bug fixed**: saved the widget's size state to local storage (in HP conversations)
15
+
16
+ # 5.1.20-rc2
17
+ - **changed**: API for upload a file/iamges
10
18
  - **changed**: marked pipe do not render /n
11
19
 
20
+ # 5.1.20-rc1
21
+ - **changed**: API for upload a file/iamges
22
+
12
23
  # 5.1.19
24
+
25
+ # 5.1.19-rc1
13
26
  - **bug fixed**: show bottom scroll button and unread message badge only when I'm not at the bottom of the page
14
27
  - **changed**: allow HTML code to be inserted into messages, but do not parse the code. Ensure coexistence with Markdown.
15
28
  - **bug fixed**: after sending a multi-line message, the text area remains open on multiple lines.
@@ -19,6 +32,7 @@
19
32
  - **changed**: saved the widget's size state to local storage. The parameter flow is (default → storage → settings → URL)
20
33
 
21
34
  # 5.1.18
35
+ # 5.1.15-rc3
22
36
  - **added**: Implemented Shadow DOM in the text component to isolate HTML and Markdown rendering in a safe and protected context
23
37
  - **changed**: Adapted text component styles to support Shadow DOM (removed ::ng-deep, added styles for common markdown elements)
24
38
  - **security**: HTML/Markdown content is now rendered in an isolated Shadow DOM, improving security and preventing interference with the rest of the application
@@ -29,6 +43,12 @@
29
43
  # 5.1.16
30
44
  - **changed**: "close chat" header conversation menu button enabled in chatbot-panel.html
31
45
 
46
+ # 5.1.15-rc2
47
+ - **bug-fixed**: Bug fix for ifame message width
48
+
49
+ # 5.1.15-rc1
50
+ - **changed**: Load local translations before remote ones
51
+
32
52
  # 5.1.15
33
53
  - **changed**: Load local translations before remote ones
34
54
 
@@ -37,14 +57,56 @@
37
57
 
38
58
  # 5.1.13
39
59
  - **bug-fixed**: set default widget size
60
+
61
+ # 5.1.7-rc16
62
+ - **bug-fixed**: set default widget size
63
+
64
+ # 5.1.7-rc15
65
+ - **bug-fixed**: set the color of the buttons with visibility control to the font color
66
+
67
+ # 5.1.7-rc14
68
+ - **bug-fixed**: departmentId and departmentName is incorrect in attributes
69
+
70
+ # 5.1.7-rc13
71
+ - **changed**: Force authentication if ageChangeVisibilityDesktop or PageChangeVisibilityMobile is OPEN
72
+
73
+ # 5.1.7-rc12
74
+ - **changed**: Set the default autoStart value to false
75
+ - **added**: Added the open widget loading spinner
76
+ - **changed**: Load the widget without authentication and display the speech bubble
77
+
78
+ # 5.1.7-rc11
79
+ - **changed**: set default value autoStart false
80
+ - **added**:added loading spinner
81
+
82
+ # 5.1.7-rc10
83
+ - **changed**: load widget without authentication and display the balloon
84
+
85
+ # 5.1.7-rc9
86
+ - **removed**: 'DOMAIN_NOT_ALLOWED' in textarea footer component
87
+
88
+ # 5.1.7-rc8
89
+ # changes in the branch
90
+ - **changed**: Load local translations before remote ones
91
+ - **bug-fixed**: set default widget size
40
92
  - **changed**: Updated the translations of the tooltips in the footer-component
41
93
  - **changed**: Refactored the network-offline component and made it generic for displaying errors (now error-alert.component)
42
- - **bug-fixed**: set the color of the buttons with visibility control to the font color (setButtonColors function)
94
+
95
+ # 5.1.7-rc7
96
+ - **bug-fixed**: button new_conversation always appear. added subscription to conversationAdded
97
+
98
+ # 5.1.7-rc6
99
+ - **added**: Added MAX_ATTACHMENT_ERROR error message when uploading a file larger than 10 MB
43
100
 
44
101
  # 5.1.12
45
102
  - **bug-fixed**: check showEmojiFooterButton to enable/disable emojii
46
103
  - **bug-fixed**: markdown is fired as an emojii and blocked by isEmojii check fn
47
104
 
105
+ # 5.1.7-rc7
106
+ - **bug-fixed**: button new_conversation always appear. added subscription to conversationAdded
107
+
108
+ # 5.1.7-rc6
109
+ - **added**: Added MAX_ATTACHMENT_ERROR error message when uploading a file larger than 10 MB
48
110
 
49
111
  # 5.1.7-rc5
50
112
  - **bug-fixed**: bug fixed BUTTON STYLES
package/Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
1
  ### STAGE 1: Build ###
2
2
 
3
3
  # We label our stage as ‘builder’
4
- FROM node:20.12.2-alpine3.19 as builder
4
+ FROM --platform=$BUILDPLATFORM node:20.12.2-alpine3.19 as builder
5
5
 
6
6
  COPY package.json package-lock.json ./
7
7
 
@@ -15,12 +15,11 @@ COPY . .
15
15
 
16
16
  ## Build the angular app in production mode and store the artifacts in dist folder
17
17
 
18
- RUN npx ng build --configuration="prod" --output-path=dist --base-href=./ --output-hashing=none
19
18
 
19
+ RUN npx ng build --configuration="prod" --output-path=dist --base-href=./ --output-hashing=none
20
20
 
21
21
  ### STAGE 2: Setup ###
22
-
23
- FROM nginx:1.14.1-alpine
22
+ FROM --platform=$BUILDPLATFORM nginx:1.14.1-alpine
24
23
 
25
24
  ## Copy our default nginx config
26
25
  COPY nginx.conf /etc/nginx/nginx.conf
@@ -33,4 +32,4 @@ COPY --from=builder /ng-app/dist/browser /usr/share/nginx/html
33
32
 
34
33
  RUN echo "Chat21 Web Widget Started!!"
35
34
 
36
- CMD ["/bin/sh", "-c", "envsubst < /usr/share/nginx/html/widget-config-template.json > /usr/share/nginx/html/widget-config.json && exec nginx -g 'daemon off;'"]
35
+ CMD ["/bin/sh", "-c", "envsubst < /usr/share/nginx/html/widget-config-template.json > /usr/share/nginx/html/widget-config.json && exec nginx -g 'daemon off;'"]
package/angular.json CHANGED
@@ -44,7 +44,8 @@
44
44
  "src/environments/real_data/widget-config-docker.json",
45
45
  "src/environments/real_data/widget-config-native-mqtt.json",
46
46
  "src/environments/real_data/widget-config-native-prod.json",
47
- "src/environments/real_data/widget-config-aws-stage.json"
47
+ "src/environments/real_data/widget-config-aws-stage.json",
48
+ "src/environments/real_data/widget-config-aws-aruba.json"
48
49
  ],
49
50
  "styles": [
50
51
  "src/app/sass/styles.scss"
@@ -2,8 +2,16 @@
2
2
  version=`node -e 'console.log(require("./package.json").version)'`
3
3
  echo "version $version"
4
4
 
5
+ npm i
6
+
7
+ cp src/environments/real_data/environment.pre.ts src/environments/environment.pre.ts
8
+
5
9
  ng build --configuration="pre" --aot=true --base-href
6
10
 
11
+ ### SET HASHING : START ###
12
+ cp ./src/launch_template.js ./dist/browser/launch.js
13
+ node ./src/build_launch.js
14
+ ### SET HASHING : END ###
7
15
 
8
16
  # ########## --->>>> NATIVE-MQTT folder START <<<<<------ ########## #
9
17
 
@@ -23,15 +31,17 @@ ng build --configuration="pre" --aot=true --base-href
23
31
 
24
32
 
25
33
  # ########## --->>>> FIREBASE folder START <<<<<------ ########## #
26
- cd dist
27
- aws s3 sync . s3://tiledesk-widget-pre/v5/$version/ --cache-control max-age=300
28
- aws s3 sync . s3://tiledesk-widget-pre/v5/ --cache-control max-age=300
29
- cd ..
30
-
31
- #aws cloudfront create-invalidation --distribution-id E3EJDWEHY08CZZ --paths "/*"
32
- cd ..
34
+ cd dist/browser
35
+ aws s3 sync . s3://tiledesk-widget-pre/v5/$version/ --cache-control max-age=300 --exclude='launch.js' #7days
36
+ aws s3 sync . s3://tiledesk-widget-pre/v5/$version/ --cache-control "no-store,no-cache,private" --exclude='*' --include='launch.js'
37
+ aws s3 sync . s3://tiledesk-widget-pre/v5/ --cache-control max-age=300 --exclude='launch.js' #7days
38
+ aws s3 sync . s3://tiledesk-widget-pre/v5/ --cache-control "no-store,no-cache,private" --exclude='*' --include='launch.js'
39
+ cd ../..
33
40
 
34
41
  aws cloudfront create-invalidation --distribution-id E2V5O0YPR61V8P --paths "/*"
42
+
43
+ git restore src/environments/environment.pre.ts
44
+
35
45
  # echo new version deployed $NEW_VER/$NEW_BUILD/ on s3://tiledesk-widget-pre/v2
36
46
  echo new version deployed $version/ on s3://tiledesk-widget-pre/v5 and s3://tiledesk-widget-pre/v5/$version/
37
47
  echo available on https://s3.eu-west-1.amazonaws.com/tiledesk-widget-pre/v5/index.html
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.1.20",
4
+ "version": "5.1.24-rc1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -145,5 +145,12 @@
145
145
  <chat-launcher-button *ngIf="isInitialized"
146
146
  (onButtonClicked)="onOpenCloseWidget($event)">
147
147
  </chat-launcher-button>
148
-
148
+
149
+ <!-- Loading Spinner -->
150
+ <div *ngIf="loading" class="tiledesk-loading-overlay">
151
+ <div class="tiledesk-loading-spinner">
152
+ <div class="spinner-circle"></div>
153
+ <div class="loading-text">{{ translationMap.get('LABEL_LOADING') }}</div>
154
+ </div>
155
+ </div>
149
156
  </div>
@@ -761,4 +761,63 @@ chat-root {
761
761
  }
762
762
  }
763
763
 
764
+ // ========= BEGIN: LOADING SPINNER ========= //
765
+ .tiledesk-loading-overlay {
766
+ position: absolute;
767
+ top: 0;
768
+ left: 0;
769
+ width: 100%;
770
+ height: 100%;
771
+ background-color: rgba(248, 249, 250, 0.95);
772
+ display: flex;
773
+ justify-content: center;
774
+ align-items: center;
775
+ z-index: 9999;
776
+ backdrop-filter: blur(2px);
777
+ }
778
+
779
+ .tiledesk-loading-spinner {
780
+ display: flex;
781
+ flex-direction: column;
782
+ align-items: center;
783
+ gap: 16px;
784
+ }
785
+
786
+ .spinner-circle {
787
+ width: 50px;
788
+ height: 50px;
789
+ border: 4px solid rgba(59, 130, 246, 0.2);
790
+ border-top-color: #3b82f6;
791
+ border-radius: 50%;
792
+ animation: spin 0.8s linear infinite;
793
+ }
794
+
795
+ @keyframes spin {
796
+ 0% {
797
+ transform: rotate(0deg);
798
+ }
799
+ 100% {
800
+ transform: rotate(360deg);
801
+ }
802
+ }
803
+
804
+ .loading-text {
805
+ font-family: var(--font-family-bubble-message, 'Roboto', 'Google Sans', Helvetica, Arial, sans-serif);
806
+ font-size: 14px;
807
+ font-weight: 500;
808
+ color: #3b82f6;
809
+ letter-spacing: 0.5px;
810
+ animation: pulse 1.5s ease-in-out infinite;
811
+ }
812
+
813
+ @keyframes pulse {
814
+ 0%, 100% {
815
+ opacity: 1;
816
+ }
817
+ 50% {
818
+ opacity: 0.5;
819
+ }
820
+ }
821
+ // ========= END: LOADING SPINNER ========= //
822
+
764
823
  }
@@ -106,6 +106,10 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
106
106
 
107
107
  forceDisconnect: boolean = false;
108
108
 
109
+ //network status
110
+ isOnline: boolean = true;
111
+ loading: boolean = false;
112
+
109
113
  // alert error message
110
114
  isShowErrorMessage: boolean = false;
111
115
  errorMessage: string = '';
@@ -149,7 +153,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
149
153
  this.logger.info('[APP-CONF]---------------- ngAfterViewInit: APP.COMPONENT ---------------- ')
150
154
 
151
155
  // Initialize translation map and enable buttons
152
- const keys = ['MAXIMIZE', 'MINIMIZE', 'CENTER', 'BUTTON_CLOSE_TO_ICON'];
156
+ const keys = ['MAXIMIZE', 'MINIMIZE', 'CENTER', 'BUTTON_CLOSE_TO_ICON', 'LABEL_LOADING'];
153
157
  this.translationMap = this.translateService.translateLanguage(keys);
154
158
  this.isButtonsDisabled = false;
155
159
 
@@ -262,7 +266,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
262
266
  this.tiledeskRequestsService.initialize(this.appConfigService.getConfig().apiUrl, this.g.projectid)
263
267
  this.messagingAuthService.initialize();
264
268
  this.chatManager.initialize();
265
- this.uploadService.initialize();
269
+ this.uploadService.initialize(this.g.projectid);
266
270
  }
267
271
 
268
272
 
@@ -316,8 +320,15 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
316
320
  this.g.setIsOpen(isOpen)
317
321
  this.appStorageService.setItem('isOpen', isOpen)
318
322
  }
319
-
320
-
323
+
324
+ if(this.g.onPageChangeVisibilityDesktop === 'last'){
325
+ this.logger.debug('[APP-COMP2] ------this.g.isOpen: ', this.g.isOpen)
326
+ if(this.g.isOpen){
327
+ this.g.autoStart = true;
328
+ }
329
+ }
330
+
331
+
321
332
  /**CHECK IF JWT IS IN URL PARAMETERS */
322
333
  this.logger.debug('[APP-COMP] check if token is passed throw url: ', this.g.jwt);
323
334
  if (this.g.jwt) {
@@ -354,10 +365,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
354
365
  this.subscriptions.push(obsSettingsService);
355
366
  this.globalSettingsService.initWidgetParamiters(this.g, this.el);
356
367
 
357
- // SET AUDIO
358
- this.audio = new Audio();
359
- this.audio.src = this.g.baseLocation + URL_SOUND_LIST_CONVERSATION;
360
- this.audio.load();
361
368
  }
362
369
 
363
370
  private initAll() {
@@ -448,7 +455,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
448
455
  that.triggerOnAuthStateChanged(that.stateLoggedUser);
449
456
  that.logger.debug('[APP-COMP] 1 - IMPOSTO STATO CONNESSO UTENTE ', autoStart);
450
457
 
451
-
458
+ this.initAudioNotification()
452
459
 
453
460
  new Promise(async (resolve, reject)=> {
454
461
  that.typingService.initialize(this.g.tenant);
@@ -474,26 +481,30 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
474
481
  that.listenToWidgetClick()
475
482
  }
476
483
 
484
+ /** DDP IF AUTOSTART IS FALSE, SHOW WIDGET */
485
+ if(!autoStart){
486
+ that.logger.info('[APP-COMP] AUTOSTART IS FALSE AND LOGGED SUCCESSFULLY ');
487
+ this.g.setParameter('isShown', true, true);
488
+ }
477
489
 
478
490
 
479
491
  } else if (state && state === AUTH_STATE_OFFLINE && !this.forceDisconnect) {
480
492
  /** non sono loggato */
481
493
  that.logger.info('[APP-COMP] OFFLINE - NO CURRENT USER AUTENTICATE: ');
482
494
  that.g.setParameter('isLogged', false);
483
- that.hideWidget();
495
+ // that.hideWidget();
484
496
  // that.g.setParameter('isShown', false, true);
485
497
  that.triggerOnAuthStateChanged(that.stateLoggedUser);
486
- if (autoStart) {
498
+ if (autoStart || this.g.onPageChangeVisibilityDesktop === 'open' || this.g.onPageChangeVisibilityMobile === 'open') {
487
499
  that.authenticate();
488
500
  }
489
- }else if(state && state === AUTH_STATE_CLOSE ){
501
+ } else if(state && state === AUTH_STATE_CLOSE ){
490
502
  that.logger.info('[APP-COMP] CLOSE - CHANNEL CLOSED: ', this.chatManager);
491
503
  if(this.g.recipientId){
492
504
  this.chatManager.removeConversationHandler(this.g.recipientId)
493
505
  this.g.recipientId = null;
494
506
  }
495
- }
496
-
507
+ }
497
508
 
498
509
  });
499
510
  this.subscriptions.push(subAuthStateChanged);
@@ -738,6 +749,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
738
749
  // divWidgetContainer.style.display = 'block';
739
750
  // }
740
751
  // }, 500);
752
+
753
+ this.loading = false;
741
754
  }
742
755
  // ========= end:: START UI ============//
743
756
 
@@ -846,7 +859,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
846
859
  this.appStorageService.setItem('attributes', JSON.stringify(attributes));
847
860
  return attributes;
848
861
  }
849
-
862
+
863
+ // SET AUDIO
864
+ private initAudioNotification(){
865
+ this.audio = new Audio();
866
+ this.audio.src = this.g.baseLocation + URL_SOUND_LIST_CONVERSATION;
867
+ this.audio.load();
868
+ }
850
869
 
851
870
  private async initConversationsHandler(tenant: string, senderId: string) {
852
871
  this.logger.debug('[APP-COMP] initialize: ListConversationsComponent');
@@ -1605,23 +1624,46 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
1605
1624
  this.f21_close();
1606
1625
  }
1607
1626
 
1627
+
1628
+ /** DDP reload widget */
1629
+ async reloadWidget() {
1630
+ this.openCloseWidget();
1631
+ this.logger.debug('[APP-COMP-1] AAA - hideWidget');
1632
+ await Promise.all([
1633
+ this.authenticate(),
1634
+ // this.initAll()
1635
+ ]);
1636
+ this.logger.debug('[APP-COMP-1] CCC - showWidget');
1637
+ }
1638
+
1639
+
1608
1640
  /**
1609
1641
  * LAUNCHER BUTTON:
1610
1642
  * onClick button open/close widget
1611
1643
  */
1612
1644
  onOpenCloseWidget($event) {
1645
+ this.logger.debug('[APP-COMP] onOpenCloseWidget', $event, this.g.isLogged);
1646
+ if(!this.g.isLogged){
1647
+ this.reloadWidget();
1648
+ } else {
1649
+ this.openCloseWidget();
1650
+ }
1651
+ }
1652
+
1653
+ /** DDP show widget */
1654
+ openCloseWidget() {
1613
1655
  this.g.setParameter('displayEyeCatcherCard', 'none');
1614
1656
  // const conversationActive: ConversationModel = JSON.parse(this.appStorageService.getItem('activeConversation'));
1615
1657
  const recipientId : string = this.appStorageService.getItem('recipientId')
1616
1658
  this.g.setParameter('recipientId', recipientId);
1617
1659
  this.logger.debug('[APP-COMP] openCloseWidget', recipientId, this.g.isOpen, this.g.startFromHome);
1660
+
1618
1661
  if (this.g.isOpen === false) {
1619
1662
  if(this.forceDisconnect){
1620
1663
  this.logger.log('[FORCE] onOpenCloseWidget --> reconnect', this.forceDisconnect)
1621
1664
  this.messagingAuthService.createCustomToken(this.g.tiledeskToken)
1622
1665
  this.forceDisconnect = false;
1623
1666
  }
1624
-
1625
1667
  if (!recipientId) {
1626
1668
  if(this.g.singleConversation){
1627
1669
  this.isOpenHome = false;
@@ -1641,29 +1683,22 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
1641
1683
  this.isOpenHome = false;
1642
1684
  this.isOpenConversation = true;
1643
1685
  this.startUI()
1644
- // this.isOpenSelectionDepartment = false;
1645
1686
  }
1646
- // if (!conversationActive && !this.g.startFromHome) {
1647
- // this.isOpenHome = false;
1648
- // this.isOpenConversation = true;
1649
- // this.startNwConversation();
1650
- // } else if (conversationActive) {
1651
- // this.isOpenHome = false;
1652
- // this.isOpenConversation = true;
1653
- // }
1654
- // this.g.startFromHome = true;
1655
1687
  this.triggerOnOpenEvent();
1656
-
1657
1688
  } else {
1658
1689
  this.triggerOnCloseEvent();
1659
1690
  }
1660
1691
  //change status to the widget
1661
1692
  this.g.setIsOpen(!this.g.isOpen);
1662
1693
  this.appStorageService.setItem('isOpen', this.g.isOpen);
1663
-
1694
+ //show loading if widget is open and user is not logged
1695
+ if(this.g.isOpen === true && !this.g.isLogged){
1696
+ this.loading = true;
1697
+ }
1664
1698
  // this.saveBadgeNewConverstionNumber();
1665
1699
  }
1666
1700
 
1701
+
1667
1702
  /**
1668
1703
  * MODAL SELECTION DEPARTMENT:
1669
1704
  * selected department
@@ -2038,27 +2073,50 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
2038
2073
  }
2039
2074
  }
2040
2075
 
2041
- onWidgetSizeChange(mode: 'min' | 'max' | 'top') {
2042
- var tiledeskDiv = this.g.windowContext.window.document.getElementById('tiledeskdiv');
2043
- this.g.size = mode;
2076
+ onWidgetSizeChange(mode: any) {
2077
+ const normalize = (val: any): 'min' | 'max' | 'top' => {
2078
+ const v = (typeof val === 'string') ? val.toLowerCase().trim() : '';
2079
+ return (v === 'min' || v === 'max' || v === 'top') ? (v as any) : 'min';
2080
+ };
2081
+ const normalizedMode = normalize(mode);
2082
+
2083
+ const tiledeskDiv = this.g.windowContext?.window?.document?.getElementById('tiledeskdiv');
2084
+ this.g.size = normalizedMode;
2085
+ if (!tiledeskDiv) {
2086
+ // Widget container not yet available; still persist choice for later restores.
2087
+ try {
2088
+ this.appStorageService.setItem('size', normalizedMode);
2089
+ } catch (e) {
2090
+ this.logger.warn('[APP-COMP] onWidgetSizeChange > cannot persist size', e);
2091
+ }
2092
+ return;
2093
+ }
2094
+
2044
2095
  let parent = tiledeskDiv.parentElement as HTMLElement | null;
2045
2096
 
2046
- if(mode==='max'){
2097
+ if(normalizedMode==='max'){
2047
2098
  tiledeskDiv.classList.add('max-size')
2048
2099
  tiledeskDiv.classList.remove('min-size')
2049
2100
  tiledeskDiv.classList.remove('top-size')
2050
2101
  if(parent) parent.classList.remove('overlay--popup');
2051
- } else if(mode==='min'){
2102
+ } else if(normalizedMode==='min'){
2052
2103
  tiledeskDiv.classList.add('min-size')
2053
2104
  tiledeskDiv.classList.remove('max-size')
2054
2105
  tiledeskDiv.classList.remove('top-size')
2055
2106
  if(parent) parent.classList.remove('overlay--popup');
2056
- } else if(mode=== 'top'){
2107
+ } else if(normalizedMode=== 'top'){
2057
2108
  tiledeskDiv.classList.add('top-size')
2058
2109
  tiledeskDiv.classList.remove('max-size')
2059
2110
  tiledeskDiv.classList.remove('min-size')
2060
2111
  if(parent) parent.classList.add('overlay--popup');
2061
2112
  }
2113
+
2114
+ // Persist size changes also from the home (conversations list) view.
2115
+ try {
2116
+ this.appStorageService.setItem('size', normalizedMode);
2117
+ } catch (e) {
2118
+ this.logger.warn('[APP-COMP] onWidgetSizeChange > cannot persist size', e);
2119
+ }
2062
2120
  }
2063
2121
 
2064
2122
  /**
@@ -470,7 +470,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
470
470
  return this.isConversationArchived;
471
471
  }
472
472
 
473
- //FALLBACK TO TILEDESK
473
+ // //FALLBACK TO TILEDESK
474
474
  const requests_list = await this.tiledeskRequestService.getMyRequests().catch(err => {
475
475
  this.logger.error('[CONV-COMP] getConversationDetail: error getting request from Tiledesk', err);
476
476
  this.isConversationArchived=true
@@ -488,9 +488,9 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
488
488
  return this.isConversationArchived
489
489
  }
490
490
 
491
- this.isConversationArchived = true;
492
- return null;
493
- }
491
+ this.isConversationArchived = false;
492
+ return null;
493
+ }
494
494
 
495
495
  /**
496
496
  * this.g.recipientId:
@@ -840,6 +840,20 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
840
840
  this.subscriptions.push(subscribe);
841
841
  }
842
842
 
843
+ subscribtionKey = 'conversationsAdded';
844
+ subscribtion = this.subscriptions.find(item => item.key === subscribtionKey);
845
+ if(!subscribtion){
846
+
847
+ subscribtion = this.chatManager.conversationsHandlerService.conversationChanged.pipe(takeUntil(this.unsubscribe$)).subscribe((conversation) => {
848
+ this.logger.debug('[CONV-COMP] ***** DATAIL conversationsChanged *****', conversation, this.conversationWith, this.isConversationArchived);
849
+ if(conversation && conversation.recipient === this.conversationId){
850
+ this.isConversationArchived = false
851
+ }
852
+ });
853
+ const subscribe = {key: subscribtionKey, value: subscribtion };
854
+ this.subscriptions.push(subscribe);
855
+ }
856
+
843
857
  subscribtionKey = 'messageWait';
844
858
  subscribtion = this.subscriptions.find(item => item.key === subscribtionKey);
845
859
  if (!subscribtion) {