podchat-browser 12.7.2-snapshot.2 → 12.7.2-snapshot.21

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.
@@ -27,7 +27,6 @@ const chatMessageVOTypes = {
27
27
  THREAD_PARTICIPANTS: 27,
28
28
  EDIT_MESSAGE: 28,
29
29
  DELETE_MESSAGE: 29,
30
- THREAD_INFO_UPDATED: 30,
31
30
  LAST_SEEN_UPDATED: 31,
32
31
  GET_MESSAGE_DELIVERY_PARTICIPANTS: 32,
33
32
  GET_MESSAGE_SEEN_PARTICIPANTS: 33,
@@ -125,6 +124,7 @@ const chatMessageVOTypes = {
125
124
  CALL_STICKER_SYSTEM_MESSAGE: 225,
126
125
  CUSTOMER_INFO: 226,
127
126
  RECALL_THREAD_PARTICIPANT: 227,
127
+ CALL_RECORDING_FAILED: 230,
128
128
  ERROR: 999
129
129
  };
130
130
 
@@ -9,6 +9,10 @@ const errorList = {
9
9
  code: 12002,
10
10
  message:"[SDK] Async is not connected"
11
11
  },
12
+ SOCKET_CONNECTION_FAILED: {
13
+ code: 12003,
14
+ message:"[SDK] Async socket connection failed"
15
+ },
12
16
  /**
13
17
  * 12350-12399
14
18
  */
@@ -0,0 +1,16 @@
1
+ import EventEmitter from "events";
2
+ const Emitter = new EventEmitter();
3
+
4
+ const storeEvents = {
5
+ on(eventName, callback) {
6
+ Emitter.on(eventName, callback)
7
+ },
8
+ off(eventName) {
9
+ Emitter.off(eventName);
10
+ },
11
+ emit(eventName, data) {
12
+ Emitter.emit(eventName, data);
13
+ }
14
+ }
15
+
16
+ export {storeEvents}
@@ -0,0 +1,9 @@
1
+ import {threadsList} from "./threads";
2
+ import {storeEvents} from "./eventEmitter";
3
+
4
+ let store = {
5
+ threads: threadsList,
6
+ events: storeEvents
7
+ };
8
+
9
+ export {store}
@@ -0,0 +1,99 @@
1
+ import {storeEvents} from "./eventEmitter";
2
+
3
+ let list = [];
4
+ const eventsList = {
5
+ UNREAD_COUNT_UPDATED: 'unreadCountUpdated',
6
+ LAST_SEEN_MESSAGE_TIME_UPDATED: 'lastSeenMessageTimeUpdated',
7
+ }
8
+
9
+ const threadsList = {
10
+ eventsList,
11
+ get(id) {
12
+ return list[threadsList.findIndex(id)];
13
+ },
14
+ getAll() {
15
+ return list;
16
+ },
17
+ findIndex(threadId) {
18
+ return list.findIndex(item => item?.get().id == threadId);
19
+ },
20
+ save(thread) {
21
+ let localThreadIndex = threadsList.findIndex(thread.id);
22
+ if (localThreadIndex > -1) {
23
+ list[localThreadIndex].set(thread)
24
+
25
+ } else {
26
+ list = [new ThreadObject(thread)].concat(list);
27
+ }
28
+ },
29
+ saveMany(newThreads) {
30
+ if (Array.isArray(newThreads)) {
31
+ let nonExistingThreads = [];
32
+ for (let item in newThreads) {
33
+ let localThreadIndex = threadsList.findIndex(newThreads[item].id);
34
+ if (localThreadIndex > -1) {
35
+ list[localThreadIndex].set(newThreads[item]);
36
+ } else {
37
+ nonExistingThreads.push(new ThreadObject(newThreads[item]));
38
+ }
39
+ }
40
+ if (nonExistingThreads.length) {
41
+ list = nonExistingThreads.concat(list);
42
+ }
43
+ }
44
+ },
45
+ remove(id) {
46
+ let localThreadIndex = threadsList.findIndex(id);
47
+ if(localThreadIndex > -1) {
48
+ delete list[localThreadIndex];
49
+ }
50
+ }
51
+ }
52
+
53
+ function ThreadObject(thread) {
54
+ const config = {
55
+ thread
56
+ };
57
+ return {
58
+ set(thread) {
59
+ config.thread = {...config.thread, ...thread};
60
+ },
61
+ get() {
62
+ return config.thread;
63
+ },
64
+ update(field, newValue) {
65
+ config.thread[field] = newValue;
66
+ },
67
+ unreadCount: {
68
+ set(count) {
69
+ config.thread.unreadCount = count;
70
+ storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
71
+ },
72
+ get() {
73
+ return config.thread.unreadCount;
74
+ },
75
+ increase() {
76
+ config.thread.unreadCount++;
77
+ storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
78
+ },
79
+ decrease(time) {
80
+ if (time > config.thread.lastSeenMessageTime && config.thread.unreadCount > 0) {
81
+ config.thread.unreadCount--;
82
+ storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
83
+ }
84
+ },
85
+ },
86
+ lastSeenMessageTime: {
87
+ set(number) {
88
+ if(number > config.thread.lastSeenMessageTime) {
89
+ config.thread.lastSeenMessageTime = number;
90
+ }
91
+ },
92
+ get() {
93
+ return config.thread.lastSeenMessageTime
94
+ }
95
+ }
96
+ };
97
+ }
98
+
99
+ export {threadsList}
@@ -27,10 +27,24 @@ import {errorList, raiseError} from "./lib/errorHandler";
27
27
  this.sendMessageCallbacks = {};
28
28
  this.messagesCallbacks = {};
29
29
  this.asyncRequestTimeouts = {};
30
- this.sendPingTimeout = null;
30
+ // this.sendPingTimeout = null;
31
31
  this.chatState = false;
32
32
  this.userInfo = null;
33
33
 
34
+ /**
35
+ * sendPingTimeout removed,
36
+ *
37
+ * TODO: remove the interval when socket statet changes to closed
38
+ */
39
+ this.startChatPing = function () {
40
+ chatPingMessageInterval = setInterval(() => {
41
+ currentModuleInstance.ping();
42
+ }, 20000) ;//TODO: chatPingMessageInterval
43
+ }
44
+ this.stopChatPing = function() {
45
+ clearInterval(chatPingMessageInterval);
46
+ }
47
+
34
48
  this.asyncInitialized = function (client) {
35
49
  asyncClient = client
36
50
  }
@@ -222,7 +236,8 @@ import {errorList, raiseError} from "./lib/errorHandler";
222
236
  ttl: (params.messageTtl > 0)
223
237
  ? params.messageTtl
224
238
  : messageTtl
225
- }
239
+ },
240
+ uniqueId: messageVO.uniqueId
226
241
  };
227
242
 
228
243
  asyncClient.send(data, function (res) {
@@ -270,10 +285,10 @@ import {errorList, raiseError} from "./lib/errorHandler";
270
285
  }, asyncRequestTimeout);
271
286
  }
272
287
 
273
- currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
288
+ /* currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
274
289
  currentModuleInstance.sendPingTimeout = setTimeout(function () {
275
290
  currentModuleInstance.ping();
276
- }, chatPingMessageInterval);
291
+ }, chatPingMessageInterval); */
277
292
 
278
293
  recursiveCallback && recursiveCallback();
279
294
 
@@ -306,9 +321,10 @@ import {errorList, raiseError} from "./lib/errorHandler";
306
321
  chatMessageVOType: chatMessageVOTypes.PING,
307
322
  pushMsgType: 3
308
323
  });
309
- } else {
310
- currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
311
324
  }
325
+ /*else {
326
+ currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
327
+ }*/
312
328
  };
313
329
 
314
330
  }