@chat21/chat21-ionic 3.0.59-rc12 → 3.0.59-rc15
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,12 @@
|
|
|
1
1
|
# chat21-ionic ver 3.0
|
|
2
2
|
|
|
3
|
+
### 3.0.59-rc15
|
|
4
|
+
- Implements a method in app.components that counts and stores the number of open Chat tabs
|
|
5
|
+
- Implements a method on the conversation list page that prevents a new chat tab from opening when the agent clicks "Open Chat" from the dashboard
|
|
6
|
+
|
|
7
|
+
### 3.0.59-rc14
|
|
8
|
+
- Fixes the bug: the sound that warns that a new conversation has been received does not work
|
|
9
|
+
|
|
3
10
|
### 3.0.59-rc12
|
|
4
11
|
- Fixes the bug: Cannot read properties of undefined (reading 'get') when "translationMap" in not yet defined
|
|
5
12
|
- Fixes the bug: when the log out is performed, the item with the number of new conversations remains visible in the left side panel of the conversations list
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -141,33 +141,32 @@ export class AppComponent implements OnInit {
|
|
|
141
141
|
public webSocketJs: WebSocketJs,
|
|
142
142
|
) {
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
this.saveInStorageNumberOfOpenedChatTab();
|
|
145
|
+
this.getPageState();
|
|
145
146
|
// FOR TEST
|
|
146
147
|
// const last_project = { "user_available": true, "number_assigned_requests": 59, "last_login_at": "2021-08-09T17:30:55.234Z", "status": "active", "_id": "6112bc8f58c958003495a2cb", "id_project": { "status": 100, "_id": "60ffe291f725db00347661ef", "name": "27-LUGLIO-21-STRIPE-TEST", "activeOperatingHours": false, "createdBy": "608ad02d3a4dc000344ade17", "profile": { "name": "pro", "trialDays": 30, "agents": 5, "type": "payment", "subStart": "2021-11-18T10:42:41.000Z", "subEnd": "2021-11-19T10:42:41.000Z", "subscriptionId": "sub_Jvf4kABe9t8JvX", "last_stripe_event": "invoice.payment_succeeded" }, "versions": 20115, "channels": [{ "name": "chat21" }], "createdAt": "2021-07-27T10:40:17.752Z", "updatedAt": "2021-11-18T11:55:01.346Z", "__v": 0, "widget": { "preChatForm": true, "preChatFormJson": [{ "name": "userFullname", "type": "text", "mandatory": true, "label": { "en": "Your name", "it": "Il tuo nome" } }, { "name": "userEmail", "type": "text", "mandatory": true, "regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/", "label": { "en": "Your email", "it": "La tua email" }, "errorLabel": { "en": "Invalid email address", "it": "Indirizzo email non valido" } }, { "name": "tel", "mandatory": true, "label": { "en": "Your phone number", "it": "Il tuo numero di telefono" } }], "preChatFormCustomFieldsEnabled": true }, "trialExpired": true, "trialDaysLeft": 84, "isActiveSubscription": true, "id": "60ffe291f725db00347661ef" }, "id_user": "60aa0fef1482fe00346854a7", "role": "admin", "createdBy": "608ad02d3a4dc000344ade17", "createdAt": "2021-08-10T17:51:11.318Z", "updatedAt": "2021-11-19T08:08:21.437Z", "__v": 0, "presence": { "status": "online", "changedAt": "2021-11-19T08:08:21.432Z" }, "isAuthenticated": true, "id": "6112bc8f58c958003495a2cb" }
|
|
147
148
|
// localStorage.setItem('last_project', JSON.stringify(last_project))
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// alert('Already open!');
|
|
152
|
-
// } else {
|
|
153
|
-
// localStorage.tabCount = 0;
|
|
154
|
-
// }
|
|
150
|
+
saveInStorageNumberOfOpenedChatTab() {
|
|
151
|
+
this.logger.log('Calling saveInStorageChatOpenedTab!');
|
|
155
152
|
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
153
|
+
// https://jsfiddle.net/jjjs5wd3/3/å
|
|
154
|
+
if (+localStorage.tabCount > 0) {
|
|
155
|
+
this.logger.log('Chat IONIC Already open!');
|
|
156
|
+
} else {
|
|
157
|
+
localStorage.tabCount = 0;
|
|
158
|
+
|
|
159
|
+
localStorage.tabCount = +localStorage.tabCount + 1;
|
|
160
|
+
}
|
|
161
|
+
const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
162
|
+
window.addEventListener(terminationEvent, (event) => {
|
|
163
|
+
localStorage.tabCount = +localStorage.tabCount - 1;
|
|
164
|
+
}, { capture: true });
|
|
165
|
+
}
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
// const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
166
|
-
// window.addEventListener(terminationEvent, (event) => {
|
|
167
|
-
// console.log('[CONVS-LIST-PAGE] page is terminationEvent', event);
|
|
168
|
-
// localStorage.tabCount = +localStorage.tabCount - 1;
|
|
169
|
-
// }, { capture: true });
|
|
167
|
+
getPageState() {
|
|
170
168
|
const getState = () => {
|
|
169
|
+
localStorage.setItem('visibilityState', document.visibilityState)
|
|
171
170
|
if (document.visibilityState === 'hidden') {
|
|
172
171
|
return 'hidden';
|
|
173
172
|
}
|
|
@@ -178,16 +177,19 @@ export class AppComponent implements OnInit {
|
|
|
178
177
|
};
|
|
179
178
|
|
|
180
179
|
let state = getState();
|
|
181
|
-
console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
182
|
-
if (state === 'hidden') {
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
// console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
181
|
+
// if (state === 'hidden') {
|
|
182
|
+
// console.log(`State change: state ${state}`);
|
|
183
|
+
// localStorage.setItem('hidden', 'true')
|
|
184
|
+
// }
|
|
185
185
|
|
|
186
186
|
const logStateChange = (nextState) => {
|
|
187
187
|
const prevState = state;
|
|
188
188
|
if (nextState !== prevState) {
|
|
189
189
|
console.log(`State change: ${prevState} >>> ${nextState}`);
|
|
190
190
|
state = nextState;
|
|
191
|
+
localStorage.setItem('state', nextState)
|
|
192
|
+
|
|
191
193
|
}
|
|
192
194
|
};
|
|
193
195
|
|
|
@@ -207,11 +209,12 @@ export class AppComponent implements OnInit {
|
|
|
207
209
|
// If the event's persisted property is `true` the page is about
|
|
208
210
|
// to enter the Back-Forward Cache, which is also in the frozen state.
|
|
209
211
|
logStateChange('frozen');
|
|
210
|
-
localStorage.setItem('
|
|
212
|
+
localStorage.setItem('state', 'frozen')
|
|
211
213
|
} else {
|
|
212
214
|
// If the event's persisted property is not `true` the page is
|
|
213
215
|
// about to be unloaded.
|
|
214
216
|
logStateChange('terminated');
|
|
217
|
+
localStorage.setItem('state', 'terminated')
|
|
215
218
|
localStorage.setItem('terminated', 'true')
|
|
216
219
|
}
|
|
217
220
|
}, { capture: true });
|
|
@@ -391,7 +394,7 @@ export class AppComponent implements OnInit {
|
|
|
391
394
|
if (this.platform.is('desktop')) {
|
|
392
395
|
// console.log("running on desktop!");
|
|
393
396
|
}
|
|
394
|
-
|
|
397
|
+
|
|
395
398
|
|
|
396
399
|
|
|
397
400
|
|
|
@@ -577,7 +580,7 @@ export class AppComponent implements OnInit {
|
|
|
577
580
|
* @param user
|
|
578
581
|
*/
|
|
579
582
|
goOnLine = () => {
|
|
580
|
-
|
|
583
|
+
// console.log('[APP-COMP] - GO-ONLINE ');
|
|
581
584
|
// this.isOnline = true;
|
|
582
585
|
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
|
|
583
586
|
|
|
@@ -624,7 +627,7 @@ export class AppComponent implements OnInit {
|
|
|
624
627
|
}
|
|
625
628
|
|
|
626
629
|
goOffLine = () => {
|
|
627
|
-
console.log('[APP-COMP] - GO-OFFLINE');
|
|
630
|
+
// console.log('[APP-COMP] - GO-OFFLINE');
|
|
628
631
|
|
|
629
632
|
this.webSocketClose()
|
|
630
633
|
// this.isOnline = false;
|
|
@@ -733,16 +736,23 @@ export class AppComponent implements OnInit {
|
|
|
733
736
|
}
|
|
734
737
|
|
|
735
738
|
private initAudio() {
|
|
739
|
+
// console.log('HERE IS initAudio ')
|
|
736
740
|
// SET AUDIO
|
|
741
|
+
const href = window.location.href;
|
|
742
|
+
const hrefArray = href.split('/#/');
|
|
743
|
+
const chatBaseUrl = hrefArray[0]
|
|
744
|
+
// console.log('initAudio href', href)
|
|
745
|
+
// console.log('initAudio chatBaseUrl', chatBaseUrl)
|
|
746
|
+
|
|
737
747
|
this.audio = new Audio();
|
|
738
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
748
|
+
this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
|
|
739
749
|
this.audio.load();
|
|
740
750
|
}
|
|
741
751
|
|
|
742
752
|
private manageTabNotification() {
|
|
743
753
|
if (!this.isTabVisible) {
|
|
744
754
|
// TAB IS HIDDEN --> manage title and SOUND
|
|
745
|
-
|
|
755
|
+
// console.log('HERE IS manageTabNotification ')
|
|
746
756
|
let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
|
|
747
757
|
badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
|
|
748
758
|
document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
|
|
@@ -761,6 +771,7 @@ export class AppComponent implements OnInit {
|
|
|
761
771
|
}
|
|
762
772
|
|
|
763
773
|
soundMessage() {
|
|
774
|
+
// console.log('HERE IS soundMessage ')
|
|
764
775
|
const that = this;
|
|
765
776
|
// this.audio = new Audio();
|
|
766
777
|
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
@@ -772,7 +783,7 @@ export class AppComponent implements OnInit {
|
|
|
772
783
|
that.audio.play().then(() => {
|
|
773
784
|
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
774
785
|
}).catch((error: any) => {
|
|
775
|
-
that.logger.
|
|
786
|
+
that.logger.error('[APP-COMP] ***soundMessage error*', error);
|
|
776
787
|
});
|
|
777
788
|
}, 1000);
|
|
778
789
|
}
|
|
@@ -79,7 +79,7 @@ export class ConversationListPage implements OnInit {
|
|
|
79
79
|
|
|
80
80
|
public displayNewConvsItem: boolean = true
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
|
|
84
84
|
constructor(
|
|
85
85
|
private router: Router,
|
|
@@ -116,8 +116,45 @@ export class ConversationListPage implements OnInit {
|
|
|
116
116
|
ngOnInit() {
|
|
117
117
|
this.watchToConnectionStatus();
|
|
118
118
|
this.getSupportMode();
|
|
119
|
+
|
|
120
|
+
const currentUrl = this.router.url;
|
|
121
|
+
this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
|
|
122
|
+
this.route.queryParams.subscribe(params => {
|
|
123
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params', params);
|
|
124
|
+
if (params && params.convselected) {
|
|
125
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params convselected:', params.convselected);
|
|
126
|
+
|
|
127
|
+
const conversationSelected = this.conversations.find(item => item.uid === params.convselected);
|
|
128
|
+
if (conversationSelected) {
|
|
129
|
+
this.conversationSelected = conversationSelected;
|
|
130
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
|
|
131
|
+
this.navigateByUrl('active', params.convselected)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
} else {
|
|
135
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
|
|
136
|
+
}
|
|
137
|
+
if (params && params.contact_id && params.contact_fullname) {
|
|
138
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
|
|
139
|
+
this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
|
|
140
|
+
this.uidConvSelected = params.contact_id
|
|
141
|
+
} else {
|
|
142
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (params && params.conversation_detail) {
|
|
146
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params conversation_detail:', params.conversation_detail);
|
|
147
|
+
this.router.navigateByUrl('conversation-detail/');
|
|
148
|
+
|
|
149
|
+
} else {
|
|
150
|
+
this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
});
|
|
119
154
|
}
|
|
120
155
|
|
|
156
|
+
|
|
157
|
+
|
|
121
158
|
getSupportMode() {
|
|
122
159
|
this.supportMode = this.appConfigProvider.getConfig().supportMode;
|
|
123
160
|
// console.log('[ION-LIST-CONVS-COMP] - supportMode ', this.supportMode)
|
|
@@ -230,19 +267,19 @@ export class ConversationListPage implements OnInit {
|
|
|
230
267
|
private listnerStart() {
|
|
231
268
|
const that = this;
|
|
232
269
|
this.chatManager.BSStart
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
270
|
+
.pipe(
|
|
271
|
+
takeUntil(that.unsubscribe$)
|
|
272
|
+
)
|
|
273
|
+
.subscribe((data: any) => {
|
|
274
|
+
this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****', data);
|
|
275
|
+
if (data) {
|
|
276
|
+
that.initialize();
|
|
277
|
+
}
|
|
278
|
+
}, error => {
|
|
279
|
+
this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error);
|
|
280
|
+
}, () => {
|
|
281
|
+
this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR * COMPLETE *')
|
|
282
|
+
});
|
|
246
283
|
}
|
|
247
284
|
|
|
248
285
|
|
|
@@ -298,7 +335,7 @@ export class ConversationListPage implements OnInit {
|
|
|
298
335
|
}
|
|
299
336
|
|
|
300
337
|
listenGoOnline() {
|
|
301
|
-
|
|
338
|
+
|
|
302
339
|
this.events.subscribe('go:online', (goonline) => {
|
|
303
340
|
this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
|
|
304
341
|
// this.events.unsubscribe('profileInfoButtonClick:logout')
|
|
@@ -308,8 +345,8 @@ export class ConversationListPage implements OnInit {
|
|
|
308
345
|
});
|
|
309
346
|
}
|
|
310
347
|
|
|
311
|
-
listenGoOffline(){
|
|
312
|
-
|
|
348
|
+
listenGoOffline() {
|
|
349
|
+
|
|
313
350
|
this.events.subscribe('go:offline', (offline) => {
|
|
314
351
|
this.logger.info('[CONVS-LIST-PAGE] - listen To go:offline - offline', offline);
|
|
315
352
|
// this.events.unsubscribe('profileInfoButtonClick:logout')
|
|
@@ -322,7 +359,7 @@ export class ConversationListPage implements OnInit {
|
|
|
322
359
|
listenToLogoutEvent() {
|
|
323
360
|
this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
|
|
324
361
|
this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
|
|
325
|
-
|
|
362
|
+
|
|
326
363
|
|
|
327
364
|
this.conversations = []
|
|
328
365
|
this.conversationsHandlerService.conversations = [];
|
|
@@ -43,7 +43,7 @@ importScripts('https://www.gstatic.com/firebasejs/5.8.6/firebase.js');
|
|
|
43
43
|
// implement this optional method.
|
|
44
44
|
// [START background_handler]
|
|
45
45
|
messaging.setBackgroundMessageHandler(function(payload) {
|
|
46
|
-
console.log('[firebase-messaging-sw.js] Received background message ', payload);
|
|
46
|
+
// console.log('[firebase-messaging-sw.js] Received background message ', payload);
|
|
47
47
|
// Customize notification here
|
|
48
48
|
const notificationTitle = 'Background Message Title';
|
|
49
49
|
const notificationOptions = {
|