@chat21/chat21-ionic 3.4.21-rc2 → 3.4.21-rc4

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
@@ -8,6 +8,12 @@
8
8
  ### **Copyrigth**:
9
9
  *Tiledesk SRL*
10
10
 
11
+ # 3.4.21-rc4
12
+ - **added**: ability to init and decrement new conversation count badge
13
+
14
+ # 3.4.21-rc3
15
+ - **changed**: badge notification for agentDesktop
16
+
11
17
  # 3.4.21-rc2
12
18
  - **added**: count in newConversation handler event
13
19
 
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.21-rc2",
4
+ "version": "3.4.21-rc4",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -1111,6 +1111,7 @@ export class AppComponent implements OnInit {
1111
1111
  if (conversation && conversation.is_new === true && this.isInitialized) {
1112
1112
  this.manageTabNotification('conv_added', conversation.sound)
1113
1113
  this.manageEventNewConversation(conversation)
1114
+ this.setNotification();
1114
1115
  }
1115
1116
  if(conversation) this.updateConversationsOnStorage()
1116
1117
  });
@@ -1345,6 +1346,9 @@ export class AppComponent implements OnInit {
1345
1346
  subscribeConversationSelected= (conversation: ConversationModel) => {
1346
1347
  if(conversation && conversation.is_new){
1347
1348
  this.audio_NewConv.pause()
1349
+
1350
+ //UPDATE NOTIFICATION FOR NEW CONVERSATION COUNT
1351
+ this.setNotification();
1348
1352
  }
1349
1353
  }
1350
1354
 
@@ -1420,6 +1424,9 @@ export class AppComponent implements OnInit {
1420
1424
  this.logger.debug('[APP-COMP]-CONVS - INIT CONV CONVS 2', conversations)
1421
1425
  this.events.publish('appcompSubscribeToConvs:loadingIsActive', false);
1422
1426
  }
1427
+
1428
+ //INIT NOTIFICATION FOR NEW CONVERSATION COUNT
1429
+ this.setNotification();
1423
1430
  });
1424
1431
 
1425
1432
  }
@@ -1633,9 +1640,18 @@ export class AppComponent implements OnInit {
1633
1640
  }
1634
1641
 
1635
1642
  private manageEventNewConversation(conversation){
1636
- this.triggerEvents.triggerOnNewConversationInit(conversation, this.conversationsHandlerService.countIsNew())
1643
+ this.triggerEvents.triggerOnNewConversationInit(conversation)
1644
+ }
1645
+
1646
+ private setNotification() {
1647
+ this.logger.log('[APP-COMP] setNotification for NEW CONVERSATION');
1648
+ if(window['AGENTDESKTOP']){
1649
+ this.logger.log('[APP-COMP] manageNotification AGENTDESKTOP exist', window['AGENTDESKTOP']);
1650
+ window['AGENTDESKTOP']['TAB'].Badge(this.conversationsHandlerService.countIsNew().toString())
1651
+ }
1637
1652
  }
1638
1653
 
1654
+
1639
1655
  @HostListener('document:visibilitychange', [])
1640
1656
  visibilitychange() {
1641
1657
  // this.logger.debug("document TITLE", document.hidden, document.title);
@@ -73,14 +73,14 @@ export class TriggerEvents {
73
73
 
74
74
  }
75
75
 
76
- public triggerOnNewConversationInit(conversation: ConversationModel, countIsNew: Number){
76
+ public triggerOnNewConversationInit(conversation: ConversationModel){
77
77
  this.logger.debug(' ---------------- triggerOnNewConversation ---------------- ', conversation);
78
78
  try {
79
- const onNewConversation = new CustomEvent('onNewConversation', { detail: { conversation: conversation, count: countIsNew} });
79
+ const onNewConversation = new CustomEvent('onNewConversation', { detail: { conversation: conversation} });
80
80
  const windowContext = this.windowContext;
81
81
  if (windowContext){
82
82
  // windowContext.document.dispatchEvent(onNewConversation);
83
- windowContext.postMessage({type: "onNewConversation", detail: { conversation: conversation, count: countIsNew}}, '*')
83
+ windowContext.postMessage({type: "onNewConversation", detail: { conversation: conversation}}, '*')
84
84
  }
85
85
  } catch (e) {
86
86
  this.logger.error('[TRIGGER-HANDLER] > Error:' + e);
@@ -12,24 +12,6 @@
12
12
  script.onload = () => {
13
13
  console.log('AgentDesktop SDK caricato');
14
14
  window.agentDesktopLoaded = true;
15
-
16
- const TILEDESK_EVENT = {
17
- AUTH_CHANGED: 'onAuthStateChanged',
18
- NEW_CONVERSATION: 'onNewConversation',
19
- }
20
-
21
- window.addEventListener( 'message', function(event){
22
- if(event && event.data && event.data.type){
23
- switch(event.data.type){
24
- case TILEDESK_EVENT.NEW_CONVERSATION: {
25
- console.log('HANDLED onNewConversation:', event.data)
26
- let count = event.data.detail.count.toString()
27
- window['AGENTDESKTOP']['TAB'].Badge(count)
28
- break;
29
- }
30
- }
31
- }
32
- })
33
15
  };
34
16
 
35
17
  script.onerror = (error) => {