@chat21/chat21-ionic 3.0.55 → 3.0.59-rc10
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 +65 -0
- package/README.md +4 -0
- package/config.xml +11 -2
- package/env.sample +2 -0
- package/package.json +1 -1
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app-routing.module.ts +21 -17
- package/src/app/app.component.html +6 -3
- package/src/app/app.component.ts +323 -185
- package/src/app/app.module.ts +16 -8
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +7 -2
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +48 -3
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
- package/src/app/components/authentication/login/login.component.html +2 -2
- package/src/app/components/authentication/login/login.component.ts +2 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
- package/src/app/components/ddp-header/ddp-header.component.html +1 -1
- package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
- package/src/app/components/image-viewer/image-viewer.component.html +23 -0
- package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
- package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
- package/src/app/components/project-item/project-item.component.html +147 -0
- package/src/app/components/project-item/project-item.component.scss +669 -0
- package/src/app/components/project-item/project-item.component.spec.ts +24 -0
- package/src/app/components/project-item/project-item.component.ts +316 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +7 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
- package/src/app/pages/authentication/login/login.page.ts +2 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
- package/src/app/pages/conversations-list/conversations-list.page.html +40 -24
- package/src/app/pages/conversations-list/conversations-list.page.scss +146 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +87 -6
- package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
- package/src/app/services/nav-proxy.service.ts +1 -1
- package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
- package/src/app/services/websocket/websocket-js.ts +559 -0
- package/src/app/services/websocket/websocket.service.spec.ts +12 -0
- package/src/app/services/websocket/websocket.service.ts +274 -0
- package/src/app/shared/shared.module.ts +7 -1
- package/src/assets/i18n/en.json +9 -1
- package/src/assets/i18n/it.json +10 -2
- package/src/assets/js/chat21client.js +141 -67
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-pre-test.json +4 -2
- package/src/chat-config-template.json +3 -1
- package/src/chat-config.json +3 -1
- package/src/chat21-core/providers/abstract/app-storage.service.ts +2 -2
- package/src/chat21-core/providers/chat-manager.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +125 -79
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +11 -17
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
- package/src/chat21-core/providers/localSessionStorage.ts +155 -154
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +1 -1
- package/src/chat21-core/utils/utils.ts +1 -1
- package/src/global.scss +2 -7
- package/src/index.html +1 -1
|
@@ -6,35 +6,35 @@ import { LoggerService } from './abstract/logger.service';
|
|
|
6
6
|
import { LoggerInstance } from './logger/loggerInstance';
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
|
-
export class LocalSessionStorage extends AppStorageService{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
export class LocalSessionStorage extends AppStorageService {
|
|
10
|
+
|
|
11
|
+
private storagePrefix: string = STORAGE_PREFIX;
|
|
12
|
+
private projectID: string;
|
|
13
|
+
private persistence: string;
|
|
14
|
+
private logger: LoggerService = LoggerInstance.getInstance();
|
|
15
|
+
|
|
16
|
+
initialize(storagePrefix: string, persistence: string, projectID: string): void {
|
|
17
|
+
this.storagePrefix = storagePrefix;
|
|
18
|
+
this.projectID = projectID;
|
|
19
|
+
this.persistence = persistence;
|
|
20
|
+
// this.persistence = 'LOCAL';
|
|
21
|
+
// this.logger.info('[LocalSessionStorage] - initialize ', this.storagePrefix, this.persistence, this.projectID)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** GET item in local/session storage from key value
|
|
25
25
|
* @param key
|
|
26
26
|
*/
|
|
27
27
|
getItem(key: string) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
let prefix;
|
|
29
|
+
try {
|
|
30
|
+
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
31
|
+
// prefix = prefix + sv;
|
|
32
|
+
prefix = this.storagePrefix + '_';
|
|
33
|
+
} catch (e) {
|
|
34
|
+
this.logger.error('[LocalSessionStorage] getItem - Error :' + e);
|
|
35
|
+
}
|
|
36
|
+
const newKey = prefix + this.projectID + '_' + key;
|
|
37
|
+
return this.getValueForKey(newKey);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** SET new item in local/session storage
|
|
@@ -42,173 +42,174 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
42
42
|
* @param value
|
|
43
43
|
*/
|
|
44
44
|
setItem(key: string, value: any): void {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
// this.removeItem(key);
|
|
46
|
+
let prefix;
|
|
47
|
+
try {
|
|
48
|
+
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
49
|
+
// prefix = prefix + sv;
|
|
50
|
+
prefix = this.storagePrefix + '_';
|
|
51
|
+
} catch (e) {
|
|
52
|
+
this.logger.error('[LocalSessionStorage] setItem > Error :' + e);
|
|
53
|
+
}
|
|
54
|
+
const newKey = prefix + this.projectID + '_' + key;
|
|
55
|
+
this.saveValueForKey(newKey, value);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** GET item in local/session storage from key value without project id SUFFIX
|
|
59
|
-
*
|
|
59
|
+
* @param key
|
|
60
|
+
* @deprecated
|
|
60
61
|
*/
|
|
61
|
-
getItemWithoutProjectID(key: string) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
62
|
+
// getItemWithoutProjectID(key: string) {
|
|
63
|
+
// let prefix;
|
|
64
|
+
// try {
|
|
65
|
+
// // const sv = 'sv' + environment.shemaVersion + '_';
|
|
66
|
+
// // prefix = prefix + sv;
|
|
67
|
+
// prefix = this.storagePrefix + '_';
|
|
68
|
+
// } catch (e) {
|
|
69
|
+
// this.logger.error('[LocalSessionStorage] getItemWithoutProjectID > Error :' + e);
|
|
70
|
+
// }
|
|
71
|
+
// const newKey = prefix + key;
|
|
72
|
+
// return this.getValueForKey(newKey);
|
|
73
|
+
// }
|
|
73
74
|
|
|
74
75
|
/** SET new item in local/session storage without project id SUFFIX
|
|
75
76
|
* @param key
|
|
76
77
|
* @param value
|
|
77
78
|
*/
|
|
78
|
-
setItemWithoutProjectID(key: string, value: any): void {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
79
|
+
// setItemWithoutProjectID(key: string, value: any): void {
|
|
80
|
+
// this.removeItem(key);
|
|
81
|
+
// let prefix = STORAGE_PREFIX;
|
|
82
|
+
// try {
|
|
83
|
+
// // const sv = 'sv' + environment.shemaVersion + '_';
|
|
84
|
+
// // prefix = prefix + sv;
|
|
85
|
+
// prefix = this.storagePrefix + '_';
|
|
86
|
+
// } catch (e) {
|
|
87
|
+
// this.logger.error('[LocalSessionStorage] setItemWithoutProjectID > Error :' + e);
|
|
88
|
+
// }
|
|
89
|
+
// const newKey = prefix + key;
|
|
90
|
+
// this.saveValueForKey(newKey, value);
|
|
91
|
+
// }
|
|
91
92
|
|
|
92
93
|
removeItem(key: string): void {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
let prefix;
|
|
95
|
+
try {
|
|
96
|
+
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
97
|
+
// prefix = prefix + sv;
|
|
98
|
+
prefix = this.storagePrefix + '_';
|
|
99
|
+
} catch (e) {
|
|
100
|
+
this.logger.error('[LocalSessionStorage] removeItem > Error :' + e);
|
|
101
|
+
}
|
|
102
|
+
const newKey = prefix + this.projectID + '_' + key;
|
|
103
|
+
return this.removeItemForKey(newKey);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
clear(): void {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
for (let i = 0; i < arrayKey.length; i++) {
|
|
124
|
-
// localStorage.removeItem(arrayKey[i]);
|
|
125
|
-
this.removeItemForKey(arrayKey[i]);
|
|
107
|
+
let prefix;
|
|
108
|
+
try {
|
|
109
|
+
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
110
|
+
// prefix = prefix + sv;
|
|
111
|
+
prefix = this.storagePrefix + '_';
|
|
112
|
+
} catch (e) {
|
|
113
|
+
this.logger.error('[LocalSessionStorage] clear > Error :' + e);
|
|
114
|
+
}
|
|
115
|
+
const prefixKey = prefix + this.projectID
|
|
116
|
+
const arrayKey: Array<string> = [];
|
|
117
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
118
|
+
const key = localStorage.key(i);
|
|
119
|
+
if (key.indexOf(prefixKey) !== -1) {
|
|
120
|
+
arrayKey.push(key);
|
|
126
121
|
}
|
|
127
|
-
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (let i = 0; i < arrayKey.length; i++) {
|
|
125
|
+
// localStorage.removeItem(arrayKey[i]);
|
|
126
|
+
this.removeItemForKey(arrayKey[i]);
|
|
127
|
+
}
|
|
128
|
+
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
|
|
131
132
|
// ---------- PRIVATE METHODS start --------------- //
|
|
132
133
|
|
|
133
134
|
private getValueForKey(key) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
135
|
+
if (this.persistence === 'local' || this.persistence === 'LOCAL') {
|
|
136
|
+
if (supports_html5_storage()) {
|
|
137
|
+
return localStorage.getItem(key);
|
|
138
|
+
} else {
|
|
139
|
+
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
} else if (this.persistence === 'session' || this.persistence === 'SESSION') {
|
|
143
|
+
if (supports_html5_session()) {
|
|
144
|
+
return sessionStorage.getItem(key);
|
|
145
|
+
} else {
|
|
146
|
+
this.logger.warn('sessionStorage is not defind. Storage disabled');
|
|
149
147
|
return null;
|
|
148
|
+
}
|
|
149
|
+
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
150
|
+
return null;
|
|
151
|
+
} else {
|
|
152
|
+
if (supports_html5_storage()) {
|
|
153
|
+
return localStorage.getItem(key);
|
|
150
154
|
} else {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
} else {
|
|
154
|
-
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
155
|
+
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
156
|
+
return null;
|
|
157
157
|
}
|
|
158
|
+
}
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
private saveValueForKey(key, value) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
162
|
+
if (this.persistence === 'local' || this.persistence === 'LOCAL') {
|
|
163
|
+
if (supports_html5_storage()) {
|
|
164
|
+
return localStorage.setItem(key, value);
|
|
165
|
+
} else {
|
|
166
|
+
this.logger.warn('localStorage is not defined. Storage disabled');
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
} else if (this.persistence === 'session' || this.persistence === 'SESSION') {
|
|
170
|
+
if (supports_html5_session()) {
|
|
171
|
+
return sessionStorage.setItem(key, value);
|
|
172
|
+
} else {
|
|
173
|
+
this.logger.warn('sessionStorage is not defined. Storage disabled');
|
|
176
174
|
return null;
|
|
175
|
+
}
|
|
176
|
+
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
177
|
+
return null;
|
|
178
|
+
} else {
|
|
179
|
+
if (supports_html5_storage()) {
|
|
180
|
+
return localStorage.setItem(key, value);
|
|
177
181
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} else {
|
|
181
|
-
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
182
|
+
this.logger.warn('localStorage is not defined. Storage disabled');
|
|
183
|
+
return null;
|
|
184
184
|
}
|
|
185
|
+
}
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
private removeItemForKey(key: string) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
189
|
+
if (this.persistence === 'local' || this.persistence === 'LOCAL') {
|
|
190
|
+
if (supports_html5_storage()) {
|
|
191
|
+
return localStorage.removeItem(key);
|
|
192
|
+
} else {
|
|
193
|
+
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
} else if (this.persistence === 'session' || this.persistence === 'SESSION') {
|
|
197
|
+
if (supports_html5_session()) {
|
|
198
|
+
return sessionStorage.removeItem(key);
|
|
199
|
+
} else {
|
|
200
|
+
this.logger.warn('sessionStorage is not defind. Storage disabled');
|
|
203
201
|
return null;
|
|
202
|
+
}
|
|
203
|
+
} else if (this.persistence === 'none' || this.persistence === 'NONE') {
|
|
204
|
+
return null;
|
|
205
|
+
} else {
|
|
206
|
+
if (supports_html5_storage()) {
|
|
207
|
+
return localStorage.removeItem(key);
|
|
204
208
|
} else {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} else {
|
|
208
|
-
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
209
|
+
this.logger.warn('localStorage is not defind. Storage disabled');
|
|
210
|
+
return null;
|
|
211
211
|
}
|
|
212
|
+
}
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
}
|
|
@@ -65,7 +65,7 @@ export class MQTTAuthService extends MessagingAuthService {
|
|
|
65
65
|
// this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'auth/signinWithCustomToken';
|
|
66
66
|
this.logger.log(' ---------------- login con token url ---------------- ');
|
|
67
67
|
// this.checkIsAuth();
|
|
68
|
-
this.onAuthStateChanged();
|
|
68
|
+
// this.onAuthStateChanged();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// logout(callback) {
|
|
@@ -103,33 +103,33 @@ z
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
*/
|
|
106
|
-
onAuthStateChanged() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
106
|
+
// onAuthStateChanged() {
|
|
107
|
+
// this.logger.log('UserService::onAuthStateChanged');
|
|
108
|
+
// // if (this.appStorage.getItem('tiledeskToken') == null) {
|
|
109
|
+
// // this.currentUser = null;
|
|
110
|
+
// this.BSAuthStateChanged.next('offline');
|
|
111
|
+
// // }
|
|
112
|
+
|
|
113
|
+
// // this.logger.log("STORAGE CHANGED: added listner")
|
|
114
|
+
// // window.addEventListener('storage', (e) => {
|
|
115
|
+
// // this.logger.log('STORAGE CHANGED:', e.key);
|
|
116
|
+
// // if (this.appStorage.getItem('tiledeskToken') == null && this.appStorage.getItem('currentUser') == null) {
|
|
117
|
+
// // this.logger.log('STORAGE CHANGED: CASO TOKEN NULL');
|
|
118
|
+
// // this.currentUser = null;
|
|
119
|
+
// // // that.logout(() => {
|
|
120
|
+
// // // that.BSAuthStateChanged.next('offline');
|
|
121
|
+
// // // });
|
|
122
|
+
// // this.logout();
|
|
123
|
+
// // }
|
|
124
|
+
// // else if (this.currentUser == null && this.appStorage.getItem('tiledeskToken') != null && this.appStorage.getItem('currentUser') != null) {
|
|
125
|
+
// // this.logger.log('STORAGE CHANGED: CASO LOGGED OUTSIDE');
|
|
126
|
+
// // this.currentUser = JSON.parse(this.appStorage.getItem('currentUser'));
|
|
127
|
+
// // const tiledeskToken = this.appStorage.getItem('tiledeskToken');
|
|
128
|
+
// // this.connectWithCustomToken(tiledeskToken);
|
|
129
|
+
// // }
|
|
130
|
+
// // }, false);
|
|
131
131
|
|
|
132
|
-
}
|
|
132
|
+
// }
|
|
133
133
|
|
|
134
134
|
createCustomToken(tiledeskToken: any): void {
|
|
135
135
|
this.connectWithCustomToken(tiledeskToken)
|
|
@@ -59,15 +59,19 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
59
59
|
// 1 search local array
|
|
60
60
|
// 2 search remote
|
|
61
61
|
// callback
|
|
62
|
-
|
|
62
|
+
console.log("SEARCHING CONV:", conversationWith);
|
|
63
63
|
const conversation = this.conversations.find(conv => conv.conversation_with === conversationWith);
|
|
64
|
-
|
|
64
|
+
console.log('[MQTTConversationsHandler] getConversationDetail *****: found locally?', conversation);
|
|
65
65
|
if (conversation) {
|
|
66
|
-
|
|
66
|
+
console.log('[MQTTConversationsHandler] getConversationDetail found LOCALLY!', conversationWith);
|
|
67
67
|
callback(conversation);
|
|
68
68
|
} else {
|
|
69
|
-
|
|
70
|
-
this.chat21Service.chatClient.conversationDetail(conversationWith, (conversation) => {
|
|
69
|
+
console.log('[MQTTConversationsHandler] getConversationDetail *****: Not found locally, SEARCHING REMOTE ', conversation);
|
|
70
|
+
this.chat21Service.chatClient.conversationDetail(conversationWith, (err, conversation) => {
|
|
71
|
+
console.log("--REMOTE CONV IS:" + conversation);
|
|
72
|
+
console.log("--REMOTE CONV IS OBJ:", conversation);
|
|
73
|
+
console.log("--REMOTE ERR IS:" + err);
|
|
74
|
+
|
|
71
75
|
if (conversation) {
|
|
72
76
|
if (callback) {
|
|
73
77
|
callback(this.completeConversation(conversation));
|
|
@@ -381,6 +385,7 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
381
385
|
}
|
|
382
386
|
|
|
383
387
|
private completeConversation(conv): ConversationModel {
|
|
388
|
+
console.log("COMPLETING CONVERSATION:", conv);
|
|
384
389
|
conv.selected = false;
|
|
385
390
|
if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
386
391
|
conv.sender_fullname = conv.sender;
|
|
@@ -413,6 +418,9 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
413
418
|
}
|
|
414
419
|
|
|
415
420
|
private isGroup(conv: ConversationModel) {
|
|
421
|
+
console.log("CONVIS: " + JSON.stringify(conv));
|
|
422
|
+
console.log("CONVIS OBJ:", conv);
|
|
423
|
+
|
|
416
424
|
if (conv.recipient.startsWith('group-') || conv.recipient.startsWith('support-group')) {
|
|
417
425
|
return true;
|
|
418
426
|
};
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import { Injectable } from '@angular/core';
|
|
3
3
|
// services
|
|
4
4
|
import { NotificationsService } from '../abstract/notifications.service';
|
|
5
|
+
import { LoggerInstance } from '../logger/loggerInstance';
|
|
6
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
7
|
+
// firebase
|
|
8
|
+
import firebase from "firebase/app";
|
|
9
|
+
import 'firebase/messaging';
|
|
10
|
+
import 'firebase/auth';
|
|
11
|
+
// chat21
|
|
12
|
+
import { Chat21Service } from './chat-service';
|
|
5
13
|
|
|
6
14
|
@Injectable({
|
|
7
15
|
providedIn: 'root'
|
|
@@ -9,24 +17,106 @@ import { NotificationsService } from '../abstract/notifications.service';
|
|
|
9
17
|
export class MQTTNotifications extends NotificationsService {
|
|
10
18
|
|
|
11
19
|
public BUILD_VERSION: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
private FCMcurrentToken: string;
|
|
21
|
+
private userId: string;
|
|
22
|
+
private tenant: string;
|
|
23
|
+
private vapidkey: string;
|
|
24
|
+
private logger: LoggerService = LoggerInstance.getInstance();
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
public chat21Service: Chat21Service
|
|
28
|
+
) {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
15
31
|
|
|
16
|
-
initialize(tenant: string): void {
|
|
17
|
-
|
|
32
|
+
initialize(tenant: string, vapId: string): void {
|
|
33
|
+
this.tenant = tenant;
|
|
34
|
+
this.vapidkey = vapId;
|
|
18
35
|
return;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
|
-
getNotificationPermissionAndSaveToken(
|
|
22
|
-
console.log(
|
|
23
|
-
|
|
38
|
+
getNotificationPermissionAndSaveToken(currentUserUid) {
|
|
39
|
+
console.log("getNotificationPermissionAndSaveToken()",currentUserUid );
|
|
40
|
+
this.userId = currentUserUid;
|
|
41
|
+
if (firebase.messaging.isSupported()) {
|
|
42
|
+
console.log("firebase.messaging.isSupported() YES");
|
|
43
|
+
const messaging = firebase.messaging();
|
|
44
|
+
// messaging.requestPermission()
|
|
45
|
+
Notification.requestPermission().then((permission) => {
|
|
46
|
+
if (permission === 'granted') {
|
|
47
|
+
this.logger.log('[MQTT-FIREBASE-NOTIFICATIONS] >>>> requestPermission Notification permission granted.');
|
|
48
|
+
|
|
49
|
+
return messaging.getToken({ vapidKey: this.vapidkey })
|
|
50
|
+
}
|
|
51
|
+
}).then(FCMtoken => {
|
|
52
|
+
this.logger.log('[MQTT-FIREBASE-NOTIFICATIONS] >>>> requestPermission FCMtoken', FCMtoken)
|
|
53
|
+
// Save FCM Token in Chat21
|
|
54
|
+
this.FCMcurrentToken = FCMtoken;
|
|
55
|
+
this.saveToken(FCMtoken, currentUserUid)
|
|
56
|
+
}).catch((err) => {
|
|
57
|
+
this.logger.error('[FIREBASE-NOTIFICATIONS] >>>> requestPermission ERR: Unable to get permission to notify.', err);
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> FIREBASE MESSAGING IS NOT SUPPORTED')
|
|
61
|
+
}
|
|
24
62
|
}
|
|
25
63
|
|
|
26
64
|
|
|
27
65
|
removeNotificationsInstance(callback: (string) => void) {
|
|
28
|
-
|
|
29
|
-
|
|
66
|
+
var self = this;
|
|
67
|
+
// firebase.auth().onAuthStateChanged(function (user) {
|
|
68
|
+
// if (user) {
|
|
69
|
+
// self.logger.debug('[FIREBASE-NOTIFICATIONS] - FB User is signed in. ', user)
|
|
70
|
+
// self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
|
|
71
|
+
// self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
|
|
72
|
+
// // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
|
|
73
|
+
// } else {
|
|
74
|
+
// self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
|
|
75
|
+
// }
|
|
76
|
+
// });
|
|
77
|
+
const urlNodeFirebase = '/apps/' + self.tenant
|
|
78
|
+
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
|
|
79
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
80
|
+
let connectionsRefURL = '';
|
|
81
|
+
if (connectionsRefinstancesId) {
|
|
82
|
+
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
83
|
+
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
84
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
|
|
85
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
|
|
86
|
+
connectionsRef.off()
|
|
87
|
+
connectionsRef.remove()
|
|
88
|
+
.then(() => {
|
|
89
|
+
self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
|
|
90
|
+
callback('success')
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
|
|
93
|
+
callback('error')
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private saveToken(FCMcurrentToken, currentUserUid) {
|
|
101
|
+
this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> getPermission > updateToken ', FCMcurrentToken);
|
|
102
|
+
if (!currentUserUid || !FCMcurrentToken) {
|
|
103
|
+
return
|
|
104
|
+
};
|
|
105
|
+
const device_model = {
|
|
106
|
+
device_model: navigator.userAgent,
|
|
107
|
+
language: navigator.language,
|
|
108
|
+
platform: 'ionic',
|
|
109
|
+
platform_version: this.BUILD_VERSION
|
|
110
|
+
}
|
|
111
|
+
this.chat21Service.chatClient.saveInstance(
|
|
112
|
+
FCMcurrentToken,
|
|
113
|
+
device_model,
|
|
114
|
+
(err, response) => {
|
|
115
|
+
if (err) {
|
|
116
|
+
this.logger.error('Error saving FCMcurrentToken on chat21 App Instance', FCMcurrentToken);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
);
|
|
30
120
|
}
|
|
31
|
-
|
|
121
|
+
|
|
32
122
|
}
|
|
@@ -35,7 +35,7 @@ export class TiledeskAuthService {
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
initialize(serverBaseUrl: string) {
|
|
38
|
-
this.logger.
|
|
38
|
+
this.logger.log('[TILEDESK-AUTH-SERV] - initialize serverBaseUrl', serverBaseUrl);
|
|
39
39
|
this.SERVER_BASE_URL = serverBaseUrl;
|
|
40
40
|
this.URL_TILEDESK_SIGNIN = this.SERVER_BASE_URL + 'auth/signin';
|
|
41
41
|
this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously'
|
|
@@ -497,7 +497,7 @@ export function createConfirm(translate, alertCtrl, events, title, message, acti
|
|
|
497
497
|
text: LABEL_ANNULLA,
|
|
498
498
|
handler: () => {
|
|
499
499
|
events.publish('PopupConfirmation', LABEL_ANNULLA, action);
|
|
500
|
-
console.log('Disagree clicked');
|
|
500
|
+
// console.log('Disagree clicked');
|
|
501
501
|
}
|
|
502
502
|
},
|
|
503
503
|
{
|
package/src/global.scss
CHANGED
|
@@ -572,19 +572,14 @@ select:-webkit-autofill:focus {
|
|
|
572
572
|
}
|
|
573
573
|
/* End rules for the member list refactoring in the "info-group.component.html" (replacement of ion-grid with ion-list) */
|
|
574
574
|
.missing-connection-toast {
|
|
575
|
-
--background
|
|
576
|
-
--color
|
|
575
|
+
--background: #fdd764;
|
|
576
|
+
--color: #2e3939;
|
|
577
577
|
font-weight: 500;
|
|
578
578
|
font-size: 16px;
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
-
|
|
582
581
|
.missing-connection-toast::part(message) {
|
|
583
582
|
// display: none;
|
|
584
583
|
display: flex;
|
|
585
584
|
align-items: center;
|
|
586
585
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|