@chat21/chat21-ionic 3.4.1 → 3.4.2

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
@@ -1,5 +1,8 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.4.2 in PROD
4
+ - added: chat21client v0.1.12.8
5
+
3
6
  ### 3.4.1 in PROD
4
7
  - bug-fixed: supportMode parameter is not typed as boolean
5
8
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.4.1",
4
+ "version": "3.4.2",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -27,7 +27,7 @@ import { CustomTranslateService } from 'src/chat21-core/providers/custom-transla
27
27
  import { NotificationsService } from 'src/chat21-core/providers/abstract/notifications.service';
28
28
  import { NetworkService } from './services/network-service/network.service';
29
29
  import { ScriptService } from './services/scripts/script.service';
30
- import { AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, PLATFORM_DESKTOP, PLATFORM_MOBILE, tranlatedLanguage, TYPE_DIRECT, URL_SOUND_CONVERSATION_ADDED, URL_SOUND_CONVERSATION_UNASSIGNED, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
30
+ import { AUTH_STATE_CLOSE, AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, PLATFORM_DESKTOP, PLATFORM_MOBILE, tranlatedLanguage, TYPE_DIRECT, URL_SOUND_CONVERSATION_ADDED, URL_SOUND_CONVERSATION_UNASSIGNED, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
31
31
  import { ActivatedRoute, Router } from '@angular/router';
32
32
  import { ConversationModel } from 'src/chat21-core/models/conversation';
33
33
  import { LoginPage } from './pages/authentication/login/login.page';
@@ -1073,8 +1073,16 @@ export class AppComponent implements OnInit {
1073
1073
  // this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
1074
1074
  this.IS_ONLINE = false;
1075
1075
  // console.log('[APP-COMP] IS_ONLINE', this.IS_ONLINE)
1076
- this.goOffLine()
1076
+ this.goOffLine();
1077
1077
  this.triggerOnAuthStateChanged(state)
1078
+ } else if(state && state === AUTH_STATE_CLOSE ){
1079
+ this.logger.info('[APP-COMP] CLOSE - CHANNEL CLOSED: ', this.chatManager);
1080
+ // let IDConv= null
1081
+ // if(this.route && this.route.snapshot && this.route.snapshot.firstChild){
1082
+ // IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
1083
+ // this.chatManager.removeConversationHandler(IDConv);
1084
+ // }
1085
+ // this.checkPlatform();
1078
1086
  }
1079
1087
  }, error => {
1080
1088
  this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
@@ -524,9 +524,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
524
524
  this.disableTextarea = false
525
525
  this._getProjectIdByConversationWith(this.conversationWith)
526
526
  this.initConversationHandler()
527
- this.initGroupsHandler()
528
- this.initSubscriptions()
529
- this.startConversation()
527
+ this.initGroupsHandler();
528
+ this.startConversation();
529
+ this.initSubscriptions();
530
530
  this.getLeadDetail()
531
531
  this.initializeTyping();
532
532
  }
@@ -879,7 +879,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
879
879
  conv.attributes['project_name'],
880
880
  conv.attributes['request_channel']
881
881
  )
882
-
883
882
  }
884
883
  if (!conv) {
885
884
  this.logger.debug('[CONV-COMP] setHeaderContent getConversationDetail: conv not exist --> search in archived list', this.conversationWith, this.conv_type)
@@ -1317,7 +1316,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1317
1316
  updateLeadInfo(msg) {
1318
1317
  if (msg.attributes && msg.attributes.hasOwnProperty("updateUserFullname")) {
1319
1318
  const userFullname = msg.attributes['updateUserFullname'];
1320
- this.logger.debug('[CONVS-DETAIL] newMessageAdded --> updateUserFullname', userFullname)
1319
+ this.logger.debug('[CONVS-DETAIL] newMessageAdded --> updateUserFullname', userFullname, this.conversation)
1321
1320
  this.conversationWithFullname = userFullname //update info for next sendMessage object
1322
1321
  //updates conversation header info
1323
1322
  this.conversationAvatar = setConversationAvatar(
@@ -7,7 +7,7 @@ export const BRAND_BASE_INFO: { [key: string] : string | boolean} ={
7
7
  FAVICON: "https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v13-300x300.png",
8
8
  META_TITLE:"Tiledesk - Open Source Live Chat",
9
9
  DOCS: true,
10
- LOGOUT_ENABLED: false
10
+ LOGOUT_ENABLED: true
11
11
  }
12
12
 
13
13
  export var LOGOS_ITEMS: { [key: string] : { label: string | boolean, icon: string }} ={
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.12.7
4
+ v0.1.12.8
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  @Member Gabriele Panico
@@ -24,6 +24,7 @@ class Chat21Client {
24
24
  this.reconnections = 0 // just to check how many reconnections
25
25
  this.client_id = this.uuidv4();
26
26
  this.log = options.log ? true : false;
27
+
27
28
  if (options && options.MQTTendpoint) {
28
29
  if (options.MQTTendpoint.startsWith('/')) {
29
30
  if (this.log) {
@@ -1021,25 +1022,31 @@ class Chat21Client {
1021
1022
  );
1022
1023
  }
1023
1024
  );
1025
+ this.client.on('error',
1026
+ (error) => {
1027
+ console.error("Chat client error event", error);
1028
+ }
1029
+ );
1030
+ }
1031
+
1032
+ onDisconnect(callback){
1024
1033
  this.client.on('reconnect',
1025
1034
  () => {
1026
1035
  if (this.log) {console.log("Chat client reconnect event");}
1036
+ // callback('reconnect')
1027
1037
  }
1028
1038
  );
1029
1039
  this.client.on('close',
1030
1040
  () => {
1031
1041
  this.connected = false
1032
1042
  if (this.log) {console.log("Chat client close event");}
1043
+ callback('close')
1033
1044
  }
1034
1045
  );
1035
1046
  this.client.on('offline',
1036
1047
  () => {
1037
1048
  if (this.log) {console.log("Chat client offline event");}
1038
- }
1039
- );
1040
- this.client.on('error',
1041
- (error) => {
1042
- console.error("Chat client error event", error);
1049
+ // callback('offline')
1043
1050
  }
1044
1051
  );
1045
1052
  }
@@ -246,8 +246,7 @@ z
246
246
  const responseType = 'text';
247
247
  const postData = {};
248
248
  // const that = this;
249
- this.http.post(this.URL_TILEDESK_CREATE_CUSTOM_TOKEN, postData, { headers, responseType})
250
- .subscribe(data => {
249
+ this.http.post(this.URL_TILEDESK_CREATE_CUSTOM_TOKEN, postData, { headers, responseType}).subscribe(data => {
251
250
  this.logger.debug("[MQTTAuthService] connectWithCustomToken: **** data", data)
252
251
  const result = JSON.parse(data);
253
252
  this.connectMQTT(result);
@@ -262,9 +261,17 @@ z
262
261
  this.chat21Service.chatClient.connect(userid, credentials.token, () => {
263
262
  this.logger.debug('[MQTTAuthService] connectMQTT: Chat connected.');
264
263
  this.BSAuthStateChanged.next('online');
264
+ this.onDisconnectMQTT();
265
265
  });
266
266
  }
267
267
 
268
+ onDisconnectMQTT(): any{
269
+ this.chat21Service.chatClient.onDisconnect((state)=> {
270
+ this.logger.debug('[MQTTAuthService] onDisconnect --> ', state)
271
+ this.BSAuthStateChanged.next('close');
272
+ })
273
+ }
274
+
268
275
  // /**
269
276
  // * createCompleteUser
270
277
  // * @param user
@@ -13,7 +13,8 @@ export const PUSH_ENGINE_FIREBASE = 'firebase';
13
13
 
14
14
  // AUTH
15
15
  export const AUTH_STATE_OFFLINE = 'offline';
16
- export const AUTH_STATE_ONLINE = 'online'
16
+ export const AUTH_STATE_ONLINE = 'online';
17
+ export const AUTH_STATE_CLOSE = 'close';
17
18
 
18
19
 
19
20
  // MESSAGES STATUS