@chat21/chat21-ionic 3.0.67 → 3.0.68

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 (52) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/deploy_amazon_prod.sh +4 -0
  3. package/package.json +1 -1
  4. package/src/app/app.component.ts +35 -17
  5. package/src/app/app.module.ts +4 -4
  6. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +8 -0
  7. package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.ts +0 -2
  8. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +1 -3
  9. package/src/app/components/conversation-info/info-content/info-content.component.ts +22 -25
  10. package/src/app/components/project-item/project-item.component.ts +28 -50
  11. package/src/app/pages/conversation-detail/conversation-detail.page.ts +47 -78
  12. package/src/app/pages/conversations-list/conversations-list.page.ts +23 -30
  13. package/src/app/pages/create-canned-response/create-canned-response.page.ts +22 -29
  14. package/src/app/services/websocket/websocket.service.ts +1 -1
  15. package/src/assets/i18n/ar.json +1 -1
  16. package/src/assets/i18n/az.json +266 -0
  17. package/src/assets/i18n/de.json +1 -1
  18. package/src/assets/i18n/en.json +1 -1
  19. package/src/assets/i18n/es.json +1 -1
  20. package/src/assets/i18n/fr.json +1 -1
  21. package/src/assets/i18n/it.json +1 -1
  22. package/src/assets/i18n/kk.json +266 -0
  23. package/src/assets/i18n/pt.json +1 -1
  24. package/src/assets/i18n/ru.json +1 -1
  25. package/src/assets/i18n/sr.json +1 -1
  26. package/src/assets/i18n/sv.json +266 -0
  27. package/src/assets/i18n/tr.json +1 -1
  28. package/src/assets/i18n/uk.json +1 -1
  29. package/src/assets/i18n/uz.json +267 -0
  30. package/src/assets/images/language_flag/az.png +0 -0
  31. package/src/assets/images/language_flag/kk.png +0 -0
  32. package/src/assets/images/language_flag/{sv-SE.png → sv.png} +0 -0
  33. package/src/assets/images/language_flag/uz.png +0 -0
  34. package/src/chat-config-mqtt-localhost.json +10 -3
  35. package/src/chat-config-pre.json +2 -1
  36. package/src/chat21-core/providers/abstract/conversations-handler.service.ts +2 -0
  37. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +0 -2
  38. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +0 -5
  39. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +45 -5
  40. package/src/chat21-core/providers/firebase/firebase-image-repo.ts +2 -1
  41. package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +71 -268
  42. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +23 -26
  43. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -24
  44. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +14 -47
  45. package/src/chat21-core/providers/mqtt/mqtt-groups-handler.ts +6 -10
  46. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +88 -93
  47. package/src/chat21-core/providers/native/native-image-repo.ts +9 -2
  48. package/src/chat21-core/providers/native/native-upload-service.ts +1 -2
  49. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +0 -1
  50. package/src/chat21-core/utils/constants.ts +1 -1
  51. package/src/chat21-core/utils/utils-message.ts +1 -1
  52. package/deploy_pre.sh +0 -44
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.68 in PROD
4
+
5
+ ### 3.0.68-rc3
6
+ - bug-fixed: not sound with unservedRequest if WebSocket restart again (every 3/5min)
7
+
8
+ ### 3.0.68-rc2
9
+ - bug-fixed: removed lookup API call for old requests
10
+
11
+ ### 3.0.68-rc1
12
+ - bug-fixed: not sound if conversation.is_new changed from true to false in conversationChange BS
13
+ - changed: if message contains only 1 emoji remove bubble message background and increase font-size
14
+ - added: new languages az, sv, kk, uz
15
+ - removed: control in info-content component for old project id with 32 characters
16
+
3
17
  ### 3.0.67 in PROD
4
18
  - added: control to 'foregroundCount' when tab is hidden/visible
5
19
  - added: sound control on/off to new conversations and conversations changed
@@ -7,9 +7,12 @@ echo 'URL_VER: ---->'$URL_VER
7
7
 
8
8
  # sed -i -e "s/$start$ver.$build/$start$NEW_VER.$NEW_BUILD/g" src/utils/constants.ts
9
9
  sed -i -e "s/$URL_VER/g" src/utils/constants.ts
10
+
11
+
10
12
  ionic cordova platform add browser --save
11
13
  #ionic cordova build --env=prod browser -- --base-href /www/ --prod
12
14
  ionic cordova build --env=prod browser --prod
15
+
13
16
  cp -p src/firebase-messaging-sw.js platforms/browser/www/
14
17
  cp -p src/manifest.json platforms/browser/www/
15
18
  cp -p src/chat-config.json platforms/browser/www/
@@ -19,6 +22,7 @@ aws s3 sync . s3://tiledesk-console/v2/chat/
19
22
  aws s3 sync . s3://tiledesk-console/v2/chat/$version/
20
23
  # aws s3 sync . s3://tiledesk-console/v2/chat/latest/
21
24
  cd ../../../
25
+
22
26
  # aws cloudfront create-invalidation --distribution-id E36UIP90GOSFPM --paths "/*"
23
27
 
24
28
  # echo new version deployed on s3://tiledesk-dashboard/chat/$NEW_BUILD/
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.0.67",
4
+ "version": "3.0.68",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -562,15 +562,13 @@ export class AppComponent implements OnInit {
562
562
  chat_lang = stored_preferred_lang
563
563
  }
564
564
 
565
- this.logger.log('[APP-COMP] - chat_lang', chat_lang)
566
-
567
565
  if (tranlatedLanguage.includes(chat_lang)) {
568
566
  this.logger.log('[APP-COMP] tranlatedLanguage includes', chat_lang, ': ', tranlatedLanguage.includes(chat_lang))
569
567
  this.translate.setDefaultLang(chat_lang)
570
568
  this.translate.use(chat_lang);
571
569
  }
572
570
  else {
573
- this.logger.log('[APP-COMP] tranlatedLanguage includes', chat_lang, ': ', tranlatedLanguage.includes(chat_lang))
571
+ this.logger.log('[APP-COMP] tranlatedLanguage not includes', chat_lang, ': ', tranlatedLanguage.includes(chat_lang))
574
572
  this.translate.setDefaultLang('en');
575
573
  this.translate.use('en');
576
574
  }
@@ -836,14 +834,16 @@ export class AppComponent implements OnInit {
836
834
  const sound_status = localStorage.getItem('dshbrd----sound')
837
835
  if(sound_status && sound_status !== 'undefined'){
838
836
  this.isSoundEnabled = sound_status === 'enabled'? true: false
837
+ }else{
838
+ this.isSoundEnabled = true
839
839
  }
840
840
 
841
841
  }
842
842
 
843
- private manageTabNotification() {
843
+ private manageTabNotification(badgeNotificationCount?: number) {
844
844
  if (!this.isTabVisible) {
845
845
  // TAB IS HIDDEN --> manage title and SOUND
846
- let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
846
+ let badgeNewConverstionNumber = badgeNotificationCount? badgeNotificationCount : this.conversationsHandlerService.countIsNew()
847
847
  badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
848
848
  document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
849
849
 
@@ -863,13 +863,13 @@ export class AppComponent implements OnInit {
863
863
  if(sound_status && sound_status !== 'undefined'){
864
864
  this.isSoundEnabled = sound_status === 'enabled'? true: false
865
865
  }
866
-
866
+ // this.logger.debug('[APP-COMP] manageTabNotification can saund?', this.isInitialized, this.isSoundEnabled)
867
867
  if(this.isInitialized && this.isSoundEnabled) this.soundMessage()
868
868
  }
869
869
 
870
870
  soundMessage() {
871
871
  const that = this;
872
- this.logger.debug('[APP-COMP] conversation play', this.audio);
872
+ // this.logger.debug('[APP-COMP] conversation play', this.audio);
873
873
  // clearTimeout(this.setTimeoutSound);
874
874
  // this.setTimeoutSound = setTimeout(function () {
875
875
  // that.audio.play().then(() => {
@@ -878,7 +878,7 @@ export class AppComponent implements OnInit {
878
878
  // that.logger.error('[APP-COMP] ***soundMessage error*', error);
879
879
  // });
880
880
  // }, 4000);
881
-
881
+
882
882
  //play sound every 4s from the fist time you receive a conversation added/changed
883
883
  if(!this.hasPlayed){
884
884
  that.audio.play().then(() => {
@@ -938,11 +938,10 @@ export class AppComponent implements OnInit {
938
938
 
939
939
  this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
940
940
  this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
941
-
941
+ this.events.subscribe('unservedRequest:count', this.subscribeUnservedRequestCount)
942
942
 
943
943
  this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
944
- this.logger.log('[APP-COMP] ***** conversationsAdded *****', conversation);
945
- // that.conversationsChanged(conversations);
944
+ // this.logger.log('[APP-COMP] ***** subscribeConversationAdded *****', conversation);
946
945
  if (conversation && conversation.is_new === true) {
947
946
  this.manageTabNotification()
948
947
  }
@@ -953,17 +952,23 @@ export class AppComponent implements OnInit {
953
952
  // console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
954
953
  if(conversation) this.updateConversationsOnStorage();
955
954
  const currentUser = this.tiledeskAuthService.getCurrentUser()
955
+ });
956
+
957
+ this.conversationsHandlerService.conversationChangedDetailed.subscribe((changes: {value: ConversationModel, previousValue: ConversationModel}) => {
958
+ // console.log('[APP-COMP] ***** subscribeConversationChangedDetailed conversation: ', changes);
959
+ const currentUser = this.tiledeskAuthService.getCurrentUser()
956
960
  if (currentUser && currentUser !== null) {
957
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged currentUser: ', currentUser);
958
- if (conversation && conversation.sender !== currentUser.uid) {
959
- this.manageTabNotification();
961
+ this.logger.log('[APP-COMP] ***** subscribeConversationChangedDetailed currentUser: ', currentUser);
962
+ if (changes.value && changes.value.sender !== currentUser.uid) {
963
+ if(changes.value.is_new === changes.previousValue.is_new){
964
+ this.manageTabNotification();
965
+ }
960
966
  }
961
967
  }
962
968
  });
963
969
 
964
970
  this.conversationsHandlerService.conversationRemoved.subscribe((conversation: ConversationModel) => {
965
971
  this.logger.log('[APP-COMP] ***** conversationRemoved *****', conversation);
966
- // that.conversationsChanged(conversations);
967
972
  if(conversation) this.updateConversationsOnStorage();
968
973
  });
969
974
  }
@@ -1037,7 +1042,8 @@ export class AppComponent implements OnInit {
1037
1042
  this.chatManager.goOffLine();
1038
1043
 
1039
1044
  this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
1040
-
1045
+ // this.goToDashboardLogin()
1046
+
1041
1047
  // clearTimeout(this.timeModalLogin);
1042
1048
  // this.timeModalLogin = setTimeout(() => {
1043
1049
  if (!this.hadBeenCalledOpenModal) {
@@ -1051,6 +1057,12 @@ export class AppComponent implements OnInit {
1051
1057
 
1052
1058
  }
1053
1059
 
1060
+ goToDashboardLogin(){
1061
+ let DASHBOARD_URL = this.appConfigProvider.getConfig().dashboardUrl + '/index.html'
1062
+ const myWindow = window.open(DASHBOARD_URL, '_self');
1063
+ myWindow.focus();
1064
+ }
1065
+
1054
1066
 
1055
1067
  webSocketClose() {
1056
1068
  this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
@@ -1131,6 +1143,12 @@ export class AppComponent implements OnInit {
1131
1143
  }
1132
1144
  }
1133
1145
 
1146
+ subscribeUnservedRequestCount = (unservedRequestCount) => {
1147
+ if(unservedRequestCount && unservedRequestCount > 0){
1148
+ this.manageTabNotification(unservedRequestCount) //sound and alternate title
1149
+ }
1150
+ }
1151
+
1134
1152
  private async presentModal(calledby): Promise<any> {
1135
1153
  this.logger.log('[APP-COMP] presentModal calledby', calledby, '- hadBeenCalledOpenModal: ', this.hadBeenCalledOpenModal);
1136
1154
  const attributes = { tenant: this.tenant, enableBackdropDismiss: false };
@@ -1240,7 +1258,7 @@ export class AppComponent implements OnInit {
1240
1258
 
1241
1259
  @HostListener('document:visibilitychange', [])
1242
1260
  visibilitychange() {
1243
- this.logger.debug("document TITLE", document.hidden, document.title);
1261
+ // this.logger.debug("document TITLE", document.hidden, document.title);
1244
1262
  if (document.hidden) {
1245
1263
  this.isTabVisible = false
1246
1264
  } else {
@@ -200,15 +200,15 @@ export function presenceFactory(appConfig: AppConfigProvider) {
200
200
  }
201
201
  }
202
202
 
203
- export function imageRepoFactory(appConfig: AppConfigProvider) {
203
+ export function imageRepoFactory(appConfig: AppConfigProvider, http: HttpClient) {
204
204
 
205
205
  const config = appConfig.getConfig()
206
206
  if (config.uploadEngine === UPLOAD_ENGINE_NATIVE) {
207
- const imageService = new NativeImageRepoService()
207
+ const imageService = new NativeImageRepoService(http)
208
208
  imageService.setImageBaseUrl(config.baseImageUrl)
209
209
  return imageService
210
210
  } else {
211
- const imageService = new FirebaseImageRepoService();
211
+ const imageService = new FirebaseImageRepoService(http);
212
212
  FirebaseInitService.initFirebase(config.firebaseConfig)
213
213
  imageService.setImageBaseUrl(config.baseImageUrl)
214
214
  return imageService
@@ -345,7 +345,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
345
345
  {
346
346
  provide: ImageRepoService,
347
347
  useFactory: imageRepoFactory,
348
- deps: [AppConfigProvider]
348
+ deps: [AppConfigProvider, HttpClient]
349
349
  },
350
350
  {
351
351
  provide: ConversationHandlerBuilderService,
@@ -45,6 +45,14 @@
45
45
  padding-top: 14px;
46
46
  }
47
47
  }
48
+
49
+ // &:hover .message-date{
50
+ // display: flex;
51
+ // }
52
+
53
+ // .message-date {
54
+ // display: none;
55
+ // }
48
56
  }
49
57
  // > .button-native
50
58
  .btn-add-msg-as-canned-response {
@@ -22,13 +22,11 @@ export class InfoMessageComponent implements OnInit, OnChanges {
22
22
  }
23
23
 
24
24
  ngOnChanges() {
25
- this.logger.debug('[INFO-COMP] message ', this.message)
26
25
  // Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly info message
27
26
  if(this.message && this.message.text) {
28
27
  var regex = /<br\s*[\/]?>/gi;
29
28
  this.message.text = this.message.text.replace(regex, "\n")
30
29
  // this.message.text = replaceEndOfLine(this.message.text);
31
- this.logger.debug('[INFO-COMP] message .text ', this.message.text )
32
30
  }
33
31
  }
34
32
 
@@ -88,7 +88,6 @@ export class IonListConversationsComponent extends ListConversationsComponent im
88
88
  // }
89
89
 
90
90
  this.currentYear = moment().format('YYYY');
91
- this.logger.log('[ION-LIST-CONVS-COMP] - currentYear ', this.currentYear)
92
91
 
93
92
  const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl;
94
93
 
@@ -99,8 +98,7 @@ export class IonListConversationsComponent extends ListConversationsComponent im
99
98
  }
100
99
  ngOnInit() {
101
100
  this.isApp = this.platform.is('ios') || this.platform.is('android')
102
- this.logger.log('[ION-LIST-CONVS-COMP] - ngOnInit - IS-APP ', this.isApp)
103
- this.logger.log('[ION-LIST-CONVS-COMP] - ngOnInit - Platform', this.platform.platforms());
101
+ this.logger.log('[ION-LIST-CONVS-COMP] - ngOnInit - IS-APP ', this.isApp);
104
102
 
105
103
  }
106
104
 
@@ -91,24 +91,21 @@ export class InfoContentComponent implements OnInit {
91
91
  const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
92
92
  this.logger.log('[INFO-CONTENT-COMP] - paramMap.subscribe lastArrayElement ', lastArrayElement);
93
93
  this.logger.log('[INFO-CONTENT-COMP] - paramMap.subscribe lastArrayElement length', lastArrayElement.length);
94
- if (lastArrayElement.length !== 32) {
95
- conversationWith_segments.pop();
96
- }
94
+ // if (lastArrayElement.length !== 32) {
95
+ // conversationWith_segments.pop();
96
+ // }
97
97
  }
98
98
 
99
99
 
100
100
  this.logger.log('[INFO-CONTENT-COMP] - paramMap.subscribe conversationWith_segments: ', conversationWith_segments);
101
101
 
102
102
  if (this.conversationWith.startsWith("support-group")) {
103
- if (conversationWith_segments.length === 4) {
103
+ // if (conversationWith_segments.length === 4) {
104
104
  this.project_id = conversationWith_segments[2];
105
-
106
105
  this.selectInfoContentTypeInfoSupportGroup();
107
-
108
- } else {
109
-
110
- this.getProjectIdByConversationWith(this.conversationWith)
111
- }
106
+ // } else {
107
+ // this.getProjectIdByConversationWith(this.conversationWith)
108
+ // }
112
109
  } else {
113
110
  this.selectInfoContentTypeDirectAndGroup(this.conversationWith);
114
111
  }
@@ -118,25 +115,25 @@ export class InfoContentComponent implements OnInit {
118
115
 
119
116
  }
120
117
 
121
- getProjectIdByConversationWith(conversationWith: string) {
122
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
118
+ // getProjectIdByConversationWith(conversationWith: string) {
119
+ // const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
123
120
 
124
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe(res => {
125
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT RES', res);
121
+ // this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe(res => {
122
+ // this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT RES', res);
126
123
 
127
- if (res) {
128
- this.project_id = res.id_project
129
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT this.project_id', this.project_id);
130
- }
124
+ // if (res) {
125
+ // this.project_id = res.id_project
126
+ // this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT this.project_id', this.project_id);
127
+ // }
131
128
 
132
- }, (error) => {
133
- this.logger.error('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
129
+ // }, (error) => {
130
+ // this.logger.error('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
134
131
 
135
- }, () => {
136
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
137
- this.selectInfoContentTypeInfoSupportGroup();
138
- });
139
- }
132
+ // }, () => {
133
+ // this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
134
+ // this.selectInfoContentTypeInfoSupportGroup();
135
+ // });
136
+ // }
140
137
 
141
138
  ngOnInit() {
142
139
  this.logger.log('>>> N INFO-CONTENT-COMP CALLING ngOnInit');
@@ -2,7 +2,7 @@ import { EventsService } from './../../services/events-service';
2
2
  import { Component, EventEmitter, HostListener, OnInit, Output } from '@angular/core';
3
3
  import { WebsocketService } from 'src/app/services/websocket/websocket.service';
4
4
  import { Subject } from 'rxjs';
5
- import { takeUntil } from 'rxjs/operators';
5
+ import { takeUntil, skip } from 'rxjs/operators';
6
6
  import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
7
7
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
8
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
@@ -66,6 +66,13 @@ export class ProjectItemComponent implements OnInit {
66
66
  this.isOnMobileDevice();
67
67
  }
68
68
 
69
+ ngOnDestroy() {
70
+ this.logger.log('[PROJECT-ITEM] > ngOnDestroy')
71
+ this.unsubscribe$.next()
72
+ this.unsubscribe$.complete()
73
+
74
+ }
75
+
69
76
  isOnMobileDevice() {
70
77
  this.IS_ON_MOBILE_DEVICE = false;
71
78
  if (/Android|iPhone/i.test(window.navigator.userAgent)) {
@@ -237,18 +244,13 @@ export class ProjectItemComponent implements OnInit {
237
244
  this.listenTocurrentProjectUserUserAvailability$(project)
238
245
 
239
246
  this.wsService.subscriptionToWsConversations(project.id_project._id)
240
- // this.updateCurrentUserRequestCount();
241
247
  this.updateUnservedRequestCount();
242
248
 
243
249
  }
244
250
  }
245
251
 
246
252
  listenTocurrentProjectUserUserAvailability$(project) {
247
- this.wsService.currentProjectUserAvailability$
248
- .pipe(
249
- takeUntil(this.unsubscribe$)
250
- )
251
- .subscribe((projectUser) => {
253
+ this.wsService.currentProjectUserAvailability$.pipe(takeUntil(this.unsubscribe$)).subscribe((projectUser) => {
252
254
  this.logger.log('[PROJECT-ITEM] - $UBSC TO WS USER AVAILABILITY & BUSY STATUS RES ', projectUser);
253
255
 
254
256
  if (project.id_project._id === projectUser['id_project']) {
@@ -276,11 +278,9 @@ export class ProjectItemComponent implements OnInit {
276
278
  available = !available
277
279
  this.logger.log('[PROJECT-ITEM] - changeAvailabilityState projectid', projectid, ' available: ', available);
278
280
 
279
- this.wsService.updateCurrentUserAvailability(this.tiledeskToken, projectid, available)
280
- .subscribe((projectUser: any) => {
281
+ this.wsService.updateCurrentUserAvailability(this.tiledeskToken, projectid, available).subscribe((projectUser: any) => {
281
282
 
282
283
  this.logger.log('[PROJECT-ITEM] - PROJECT-USER UPDATED ', projectUser)
283
-
284
284
  // NOTIFY TO THE USER SERVICE WHEN THE AVAILABLE / UNAVAILABLE BUTTON IS CLICKED
285
285
  // this.usersService.availability_btn_clicked(true)
286
286
 
@@ -300,24 +300,27 @@ export class ProjectItemComponent implements OnInit {
300
300
 
301
301
  updateUnservedRequestCount() {
302
302
 
303
- this.wsService.wsRequestsList$
304
- .subscribe((requests) => {
305
- if (requests) {
306
- let count = 0;
307
- requests.forEach(r => {
308
- if (r['status'] === 100) {
309
- if (this.hasmeInAgents(r['agents']) === true) {
310
- count = count + 1;
311
- }
303
+ this.wsService.wsRequestsList$.pipe(takeUntil(this.unsubscribe$)).pipe(skip(1)).subscribe((requests) => {
304
+ if (requests) {
305
+ let count = 0;
306
+ requests.forEach(r => {
307
+ if (r['status'] === 100) {
308
+ if (this.hasmeInAgents(r['agents']) === true) {
309
+ count = count + 1;
312
310
  }
313
- });
311
+ }
312
+ });
313
+ //not sound if unservedRequest is already chached and web-sk is closed and restart again
314
+ if(this.unservedRequestCount < count){
314
315
  this.unservedRequestCount = count;
316
+ this.events.publish('unservedRequest:count', this.unservedRequestCount)
315
317
  }
316
- }, error => {
317
- this.logger.error('[PROJECT-ITEM] UNSERVED REQUEST COUNT * error * ', error)
318
- }, () => {
319
- this.logger.log('[PROJECT-ITEM] UNSERVED REQUEST COUNT */* COMPLETE */*')
320
- })
318
+ }
319
+ }, error => {
320
+ this.logger.error('[PROJECT-ITEM] UNSERVED REQUEST COUNT * error * ', error)
321
+ }, () => {
322
+ this.logger.log('[PROJECT-ITEM] UNSERVED REQUEST COUNT */* COMPLETE */*')
323
+ })
321
324
  }
322
325
 
323
326
  hasmeInAgents(agents) {
@@ -332,31 +335,6 @@ export class ProjectItemComponent implements OnInit {
332
335
  }
333
336
  }
334
337
 
335
- updateCurrentUserRequestCount() {
336
- this.wsService.wsRequestsList$
337
- .pipe(
338
- takeUntil(this.unsubscribe$)
339
- )
340
- .subscribe((requests) => {
341
- if (requests) {
342
- let count = 0;
343
- requests.forEach(r => {
344
- const participantsArray = r['participants'] // new used with ws
345
-
346
- const currentUserIsInParticipants = participantsArray.includes(this.currentUserId); // new used with ws
347
- if (currentUserIsInParticipants === true) {
348
- count = count + 1;
349
- }
350
- });
351
- this.currentUserRequestCount = count;
352
- this.logger.log('[PROJECT-ITEM] CURRENT USER REQUEST COUNT - RES', this.currentUserRequestCount);
353
- }
354
- }, error => {
355
- this.logger.error('[PROJECT-ITEM] CURRENT USER REQUEST COUNT * error * ', error)
356
- }, () => {
357
- this.logger.log('[PROJECT-ITEM] CURRENT USER REQUEST COUNT */* COMPLETE */*')
358
- })
359
- }
360
338
 
361
339
 
362
340
 
@@ -259,7 +259,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
259
259
  listenToDsbrdPostMsgs() {
260
260
 
261
261
  window.addEventListener("message", (event) => {
262
- this.logger.log("[CONVS-DETAIL] message event ", event);
262
+ // this.logger.log("[CONVS-DETAIL] message event ", event);
263
263
 
264
264
  // const chat21InfoConversationEle = <HTMLElement>document.querySelector('#chat21-info-conversation');
265
265
  // console.log('[CONVS-DETAIL] HAS CLICKED ENLARGE SIDEBAR WIDE chat21InfoConversationEle ', chat21InfoConversationEle)
@@ -531,55 +531,33 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
531
531
  _getProjectIdByConversationWith(conversationWith: string) {
532
532
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
533
533
 
534
- this.tiledeskService
535
- .getProjectIdByConvRecipient(tiledeskToken, conversationWith)
536
- .subscribe(
537
- (res) => {
538
- this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
539
- if (res) {
540
- const projectId = res.id_project
541
- this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
542
- this.getProjectById(tiledeskToken, projectId)
543
- }
544
- },
545
- (error) => {
546
- this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
547
- },
548
- () => {
549
- this.logger.log(
550
- '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
551
- )
552
- },
553
- )
534
+ this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
535
+ this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES + projectId', res, res.id_project)
536
+ if (res) {
537
+ const projectId = res.id_project
538
+ this.getProjectById(tiledeskToken, projectId)
539
+ }
540
+ },(error) => {
541
+ this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
542
+ },() => {
543
+ this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',)
544
+ })
554
545
  }
555
546
 
556
547
  getProjectById(tiledeskToken, projectId) {
557
- this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe(
558
- (res) => {
559
- this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
560
- if (res) {
561
- const projectId = res.id_project
562
- this.logger.log(
563
- '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ',
564
- projectId,
565
- )
566
- }
567
- },
568
- (error) => {
569
- this.logger.error(
570
- '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
571
- error,
572
- )
573
- if ((error.error.msg = 'you dont belong to the project.')) {
574
- this.disableTextarea = true
575
- }
576
- },
577
- () => {
578
- this.logger.log(
579
- '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
580
- )
581
- },
582
- )
548
+ this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe((res) => {
549
+ this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
550
+ if (res) {
551
+ const projectId = res.id_project
552
+ }
553
+ },(error) => {
554
+ this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',error)
555
+ if ((error.error.msg = 'you dont belong to the project.')) {
556
+ this.disableTextarea = true
557
+ }
558
+ },() => {
559
+ this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
560
+ })
583
561
  }
584
562
 
585
563
  returnOpenCloseInfoConversation(openInfoConversation: boolean) {
@@ -1251,45 +1229,36 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1251
1229
  conversationWith_segments.pop()
1252
1230
  }
1253
1231
 
1254
- if (conversationWith_segments.length === 4) {
1255
- const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
1256
- this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement)
1257
- this.logger.log('[CONVS-DETAIL] - lastArrayElement length', lastArrayElement.length)
1258
- if (lastArrayElement.length !== 32) {
1259
- conversationWith_segments.pop()
1260
- }
1261
- }
1262
-
1263
1232
  this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ', conversationWith_segments)
1264
1233
  let projectId = ''
1265
1234
 
1266
- if (conversationWith_segments.length === 4) {
1235
+ // if (conversationWith_segments.length === 4) {
1267
1236
  projectId = conversationWith_segments[2]
1268
1237
  this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
1269
1238
  this.getAndShowCannedResponses(strSearch, projectId)
1270
- } else {
1271
- this.getProjectIdByConversationWith(strSearch, this.conversationWith)
1272
- }
1239
+ // } else {
1240
+ // this.getProjectIdByConversationWith(strSearch, this.conversationWith)
1241
+ // }
1273
1242
  }
1274
1243
 
1275
- getProjectIdByConversationWith(strSearch, conversationWith: string) {
1276
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1277
-
1278
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
1279
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
1280
- if (res) {
1281
- const projectId = res.id_project
1282
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
1283
- if (projectId) {
1284
- this.getAndShowCannedResponses(strSearch, projectId)
1285
- }
1286
- }
1287
- }, (error) => {
1288
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
1289
- }, () => {
1290
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
1291
- })
1292
- }
1244
+ // getProjectIdByConversationWith(strSearch, conversationWith: string) {
1245
+ // const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1246
+
1247
+ // this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
1248
+ // this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
1249
+ // if (res) {
1250
+ // const projectId = res.id_project
1251
+ // this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
1252
+ // if (projectId) {
1253
+ // this.getAndShowCannedResponses(strSearch, projectId)
1254
+ // }
1255
+ // }
1256
+ // }, (error) => {
1257
+ // this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
1258
+ // }, () => {
1259
+ // this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
1260
+ // })
1261
+ // }
1293
1262
 
1294
1263
  getAndShowCannedResponses(strSearch, projectId) {
1295
1264
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()