@aochuang/client-sdk 1.0.363 → 1.0.365
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/components/index.js +1 -6
- package/components/layout/layout.vue +4 -1
- package/components/session-select/session-select-item.vue +9 -8
- package/components/wechat-chat-control/image/image.vue +8 -13
- package/components/wechat-chat-control/url/url-miniprogram.vue +5 -1
- package/components/wework-chat-control/channel-live/channel-live.vue +2 -7
- package/components/wework-chat-control/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/custom-expression/custom-expression.vue +1 -2
- package/components/wework-chat-control/file-url/file-url.vue +16 -34
- package/components/wework-chat-control/image/image.vue +2 -137
- package/components/wework-chat-control/index.js +7 -15
- package/components/wework-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +2 -3
- package/components/wework-chat-control/text/text.vue +144 -24
- package/components/wework-chat-control/url/url-miniprogram.vue +7 -6
- package/components/wework-chat-control/url/url.vue +2 -26
- package/components/wework-chat-control/util.js +17 -26
- package/components/wework-chat-control/video/video.vue +2 -10
- package/components/wework-chat-control/voice/voice.vue +2 -9
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
- package/components/wework-chat-panel/chat-panel-item.vue +25 -56
- package/components/wework-chat-panel/chat-panel.vue +13 -96
- package/package.json +3 -10
- package/services/client-chat/client-chat-wechat/client-chat-session.js +290 -79
- package/services/client-chat/client-chat-wechat/client-chat.js +69 -99
- package/services/client-chat/client-chat-wework/client-chat-account.js +1 -84
- package/services/client-chat/client-chat-wework/client-chat-concats.js +17 -81
- package/services/client-chat/client-chat-wework/client-chat-message.js +5 -45
- package/services/client-chat/client-chat-wework/client-chat-session.js +4 -59
- package/services/client-chat/client-chat-wework/client-chat-socket.js +1 -13
- package/services/client-chat/client-chat-wework/client-chat.js +11 -320
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/uni-common/account-portray/account-portray.vue +51 -0
- package/uni-common/account-select/account-select-item.vue +172 -0
- package/uni-common/account-select/account-select.vue +252 -0
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
- package/uni-common/friend-avatar/default.svg +1 -0
- package/uni-common/friend-avatar/friend-avatar.vue +27 -0
- package/uni-common/friend-avatar/index.js +3 -0
- package/uni-common/friend-loader/friend-loader.vue +53 -0
- package/uni-common/friend-portray/friend-portray.vue +56 -0
- package/uni-common/group-avatar/default.svg +1 -0
- package/uni-common/group-avatar/group-avatar.vue +18 -0
- package/uni-common/group-avatar/index.js +3 -0
- package/uni-common/room-avatar/default.svg +6 -0
- package/uni-common/room-avatar/index.js +3 -0
- package/uni-common/room-avatar/room-avatar.vue +27 -0
- package/uni-common/room-loader/room-loader.vue +53 -0
- package/uni-common/room-portray/room-portray.vue +56 -0
- package/uni-components/chat-control/calling/calling.vue +91 -0
- package/uni-components/chat-control/calling/phone-fill.svg +1 -0
- package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
- package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
- package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
- package/{components/wework-chat-control/wework-chat-control-config.vue → uni-components/chat-control/chat-control-config.vue} +13 -16
- package/uni-components/chat-control/chat-control.vue +218 -0
- package/uni-components/chat-control/company-card/company-card.vue +123 -0
- package/uni-components/chat-control/const.js +28 -0
- package/uni-components/chat-control/expression/expression.vue +41 -0
- package/uni-components/chat-control/image/image.vue +68 -0
- package/uni-components/chat-control/index.js +89 -0
- package/uni-components/chat-control/location/location.vue +110 -0
- package/uni-components/chat-control/member-change/member-change.vue +32 -0
- package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
- package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
- package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
- package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
- package/uni-components/chat-control/share-card/share-card.vue +101 -0
- package/uni-components/chat-control/system/system.vue +69 -0
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
- package/uni-components/chat-control/system-text/system-text.vue +32 -0
- package/uni-components/chat-control/text/text.vue +67 -0
- package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
- package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
- package/uni-components/chat-control/transfer/transfer.vue +80 -0
- package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
- package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url/icons/index.js +24 -0
- package/uni-components/chat-control/url/miniprogram.svg +1 -0
- package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
- package/uni-components/chat-control/url/url.vue +306 -0
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/index.js +24 -0
- package/uni-components/chat-control/url-new/url-new.vue +110 -0
- package/uni-components/chat-control/utils.js +12 -0
- package/uni-components/chat-control/video/video.vue +156 -0
- package/uni-components/chat-control/voice/voice.vue +166 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
- package/uni-components/chat-editor/chat-editor.vue +257 -0
- package/uni-components/chat-editor/index.js +10 -0
- package/uni-components/chat-editor/util.js +65 -0
- package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
- package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
- package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
- package/uni-components/chat-panel/chat-panel.vue +227 -0
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
- package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
- package/common/.DS_Store +0 -0
- package/components/.DS_Store +0 -0
- package/components/wechat-chat-control/.DS_Store +0 -0
- package/components/wechat-chat-control/transfer/.DS_Store +0 -0
- package/components/wechat-chat-control/url/.DS_Store +0 -0
- package/components/wechat-chat-control/voice/.DS_Store +0 -0
- package/components/wework-chat-control/channel-card/channel-card.vue +0 -144
- package/components/wework-chat-control/link/.DS_Store +0 -0
- package/components/wework-chat-control/merge-message/merge-message-panel.vue +0 -63
- package/components/wework-chat-control/merge-message/merge-message.vue +0 -84
- package/components/wework-chat-control/merge-message/util.js +0 -59
- package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
- package/components/wework-chat-control/metting/meeting-video.svg +0 -4
- package/components/wework-chat-control/metting/metting.vue +0 -181
- package/components/wework-chat-control/text/text-default.vue +0 -99
- package/components/wework-chat-control/text/text-quote.vue +0 -105
- package/components/wework-chat-control/url/url-channel-live.vue +0 -53
- package/components/wework-chat-control/video/.DS_Store +0 -0
- package/components/wework-chat-control/wework-chat-control-config-item.vue +0 -24
- package/components/wework-chat-control/wework-chat-control-config-msg.vue +0 -25
- package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +0 -73
- package/services/.DS_Store +0 -0
|
@@ -131,6 +131,7 @@ export default class ClientChatSession {
|
|
|
131
131
|
stickyTopSessionMethod: null,
|
|
132
132
|
muteNotificationSessionMethod: null,
|
|
133
133
|
getSessionMethod: null,
|
|
134
|
+
onGetSessionLog: null,
|
|
134
135
|
updateSessionReadMethod: null,
|
|
135
136
|
starSessionMethod: null,
|
|
136
137
|
unstarSessionMethod: null,
|
|
@@ -166,6 +167,7 @@ export default class ClientChatSession {
|
|
|
166
167
|
this.loadSessionData = options.loadSessionDataMethod
|
|
167
168
|
this.updateSessionRead = options.updateSessionReadMethod
|
|
168
169
|
this.getSessionMethod = options.getSessionMethod
|
|
170
|
+
this.onGetSessionLog = options.onGetSessionLog
|
|
169
171
|
this.loadAssignTaskSessionDataMethod = options.loadAssignTaskSessionDataMethod
|
|
170
172
|
this.stickyTopSessionMethod = options.stickyTopSessionMethod
|
|
171
173
|
this.muteNotificationSessionMethod = options.muteNotificationSessionMethod
|
|
@@ -228,51 +230,144 @@ export default class ClientChatSession {
|
|
|
228
230
|
})
|
|
229
231
|
}
|
|
230
232
|
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
_addGetSessionLog (title, data) {
|
|
234
|
+
if (this.onGetSessionLog) {
|
|
235
|
+
this.onGetSessionLog({
|
|
236
|
+
group: 'client-chat-session:getSession',
|
|
237
|
+
content: {
|
|
238
|
+
title,
|
|
239
|
+
data
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_addGetSessionSerializeTask (pollRequest, serializeMethod, taskOptions = {}) {
|
|
246
|
+
if (!serializeMethod) {
|
|
247
|
+
return false
|
|
248
|
+
}
|
|
249
|
+
const messageId = taskOptions.messageId
|
|
250
|
+
if (messageId && pollRequest.serializeTaskMap[messageId]) {
|
|
251
|
+
return false
|
|
252
|
+
}
|
|
253
|
+
const task = {
|
|
254
|
+
messageId,
|
|
255
|
+
wechatTime: taskOptions.wechatTime || 0,
|
|
256
|
+
index: pollRequest.serializeTasks.length,
|
|
257
|
+
serializeMethod
|
|
258
|
+
}
|
|
259
|
+
pollRequest.serializeTasks.push(task)
|
|
260
|
+
if (messageId) {
|
|
261
|
+
pollRequest.serializeTaskMap[messageId] = task
|
|
235
262
|
}
|
|
263
|
+
return true
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
getSession (sessionId, serializeMethod, taskOptions = {}) {
|
|
236
267
|
if (this.sessionMap[sessionId]) {
|
|
237
268
|
return Promise.resolve({
|
|
238
269
|
data: this.sessionMap[sessionId]
|
|
239
270
|
})
|
|
240
271
|
}
|
|
241
272
|
// 这里需要轮询从后端获取会话,后端会话更新和创建是异步的,所以要多轮训请求几次
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
273
|
+
let pollRequest = this.pollRequestMap[sessionId]
|
|
274
|
+
if (pollRequest && pollRequest.ps) {
|
|
275
|
+
const taskAdded = this._addGetSessionSerializeTask(pollRequest, serializeMethod, taskOptions)
|
|
276
|
+
this._addGetSessionLog('复用会话轮询', {
|
|
277
|
+
sessionId,
|
|
278
|
+
messageId: taskOptions.messageId,
|
|
279
|
+
wechatTime: taskOptions.wechatTime,
|
|
280
|
+
taskAdded,
|
|
281
|
+
taskCount: pollRequest.serializeTasks.length
|
|
282
|
+
})
|
|
283
|
+
return pollRequest.ps
|
|
249
284
|
}
|
|
250
|
-
|
|
285
|
+
|
|
286
|
+
pollRequest = createPollRequest(({ done }) => {
|
|
287
|
+
pollRequest.requestCount += 1
|
|
251
288
|
return this.getSessionMethod({
|
|
252
289
|
id: sessionId
|
|
253
290
|
}).then((rs) => {
|
|
254
291
|
if (rs.data) {
|
|
255
292
|
done(rs)
|
|
293
|
+
} else {
|
|
294
|
+
this._addGetSessionLog('会话轮询返回空', {
|
|
295
|
+
sessionId,
|
|
296
|
+
requestCount: pollRequest.requestCount
|
|
297
|
+
})
|
|
256
298
|
}
|
|
299
|
+
}, (error) => {
|
|
300
|
+
this._addGetSessionLog('会话轮询请求异常', {
|
|
301
|
+
sessionId,
|
|
302
|
+
requestCount: pollRequest.requestCount,
|
|
303
|
+
error: error && (error.message || error.errMsg || error.toString && error.toString()) || error
|
|
304
|
+
})
|
|
305
|
+
return Promise.reject(error)
|
|
257
306
|
})
|
|
258
307
|
})
|
|
308
|
+
pollRequest.serializeTasks = []
|
|
309
|
+
pollRequest.serializeTaskMap = {}
|
|
310
|
+
pollRequest.requestCount = 0
|
|
311
|
+
pollRequest.startedAt = Date.now()
|
|
312
|
+
this._addGetSessionSerializeTask(pollRequest, serializeMethod, taskOptions)
|
|
259
313
|
this.pollRequestMap[sessionId] = pollRequest
|
|
260
|
-
this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
314
|
+
this._addGetSessionLog('创建会话轮询', {
|
|
315
|
+
sessionId,
|
|
316
|
+
messageId: taskOptions.messageId,
|
|
317
|
+
wechatTime: taskOptions.wechatTime,
|
|
318
|
+
taskCount: pollRequest.serializeTasks.length
|
|
319
|
+
})
|
|
320
|
+
pollRequest.ps = pollRequest.start().then(rs => {
|
|
321
|
+
if (!rs.data) {
|
|
268
322
|
return Promise.reject('未找到会话' + sessionId)
|
|
269
323
|
}
|
|
324
|
+
const context = {
|
|
325
|
+
baseLastMsgTime: rs.data.lastMsgTime || 0,
|
|
326
|
+
processedMessageIds: [],
|
|
327
|
+
skippedMessageIds: [],
|
|
328
|
+
unreadMessageIds: []
|
|
329
|
+
}
|
|
330
|
+
const serializeTasks = pollRequest.serializeTasks.slice().sort((a, b) => {
|
|
331
|
+
return a.wechatTime - b.wechatTime || a.index - b.index
|
|
332
|
+
})
|
|
333
|
+
serializeTasks.forEach(task => {
|
|
334
|
+
rs = task.serializeMethod(rs, context) || rs
|
|
335
|
+
if (task.messageId) {
|
|
336
|
+
context.processedMessageIds.push(task.messageId)
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
this.addSession(rs.data, null)
|
|
340
|
+
const wechatAccountId = rs.data.wechatAccountId
|
|
341
|
+
this._addGetSessionLog('会话轮询合并完成', {
|
|
342
|
+
sessionId,
|
|
343
|
+
requestCount: pollRequest.requestCount,
|
|
344
|
+
duration: Date.now() - pollRequest.startedAt,
|
|
345
|
+
baseLastMsgTime: context.baseLastMsgTime,
|
|
346
|
+
lastMsgTime: rs.data.lastMsgTime,
|
|
347
|
+
lastMsgId: rs.data.lastMsgId,
|
|
348
|
+
unreadMsgCount: rs.data.unreadMsgCount,
|
|
349
|
+
processedMessageIds: context.processedMessageIds,
|
|
350
|
+
skippedMessageIds: context.skippedMessageIds,
|
|
351
|
+
unreadMessageIds: context.unreadMessageIds,
|
|
352
|
+
hasSessionMap: !!this.sessionMap[sessionId],
|
|
353
|
+
hasAllSessionGroup: !!this._getSessionBySessionGroup(sessionId, ALL_WECHAT_ACCOUNT_ID),
|
|
354
|
+
hasAccountSessionGroup: !!this._getSessionBySessionGroup(sessionId, wechatAccountId)
|
|
355
|
+
})
|
|
356
|
+
return rs
|
|
357
|
+
}).catch((error) => {
|
|
358
|
+
this._addGetSessionLog('会话轮询失败', {
|
|
359
|
+
sessionId,
|
|
360
|
+
requestCount: pollRequest.requestCount,
|
|
361
|
+
duration: Date.now() - pollRequest.startedAt,
|
|
362
|
+
error: error && (error.message || error.errMsg || error.toString && error.toString()) || error
|
|
363
|
+
})
|
|
364
|
+
return Promise.reject(error)
|
|
270
365
|
}).finally(() => {
|
|
271
366
|
if (this.pollRequestMap[sessionId] === pollRequest) {
|
|
272
367
|
delete this.pollRequestMap[sessionId]
|
|
273
368
|
}
|
|
274
369
|
})
|
|
275
|
-
return
|
|
370
|
+
return pollRequest.ps
|
|
276
371
|
}
|
|
277
372
|
|
|
278
373
|
findSession (findFn) {
|
|
@@ -397,7 +492,7 @@ export default class ClientChatSession {
|
|
|
397
492
|
* "wechatAccountId": "2a39a725814acf07502299ab2285fff8d44377f5"
|
|
398
493
|
* }
|
|
399
494
|
*/
|
|
400
|
-
addSession (data, wechatAccountId
|
|
495
|
+
addSession (data, wechatAccountId) {
|
|
401
496
|
if (!data || !data.conversationId) {
|
|
402
497
|
throw new Error('缺少必须参数conversationId')
|
|
403
498
|
}
|
|
@@ -412,56 +507,53 @@ export default class ClientChatSession {
|
|
|
412
507
|
}) === false) {
|
|
413
508
|
return
|
|
414
509
|
}
|
|
415
|
-
|
|
510
|
+
if (wechatAccountId && wechatAccountId !== ALL_WECHAT_ACCOUNT_ID && data.wechatAccountId !== wechatAccountId) {
|
|
511
|
+
throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
|
|
512
|
+
}
|
|
513
|
+
let nextData = null
|
|
514
|
+
let isRefreshAll = false
|
|
515
|
+
let groupIds = []
|
|
416
516
|
// 如果会话已经存在,那么取已经存在的,以后有需要可以用data更新已经存在的会话,保持引用关系
|
|
517
|
+
// 一般比较容易出现,例如all的时候,分配的时候有可能会出现,例如以前的会话没有正确删除,后面有分配过来了
|
|
417
518
|
if (this.sessionMap[data.conversationId]) {
|
|
519
|
+
// 如果会话比较老,就不更新属性
|
|
520
|
+
if (this.sessionMap[data.conversationId].lastMsgTime && data.lastMsgTime && this.sessionMap[data.conversationId].lastMsgTime <= data.lastMsgTime) {
|
|
521
|
+
// 先删后插
|
|
522
|
+
this._removeSessionBySessionGroup(this.sessionMap[data.conversationId].conversationId)
|
|
523
|
+
// 更新属性
|
|
524
|
+
Object.keys(data).forEach(k => {
|
|
525
|
+
Vue.set(this.sessionMap[data.conversationId], k, data[k])
|
|
526
|
+
})
|
|
527
|
+
}
|
|
418
528
|
nextData = this.sessionMap[data.conversationId]
|
|
529
|
+
isRefreshAll = true
|
|
419
530
|
} else {
|
|
420
|
-
|
|
531
|
+
nextData = data
|
|
421
532
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
|
|
533
|
+
if (!nextData) {
|
|
534
|
+
return
|
|
425
535
|
}
|
|
426
|
-
const groupIds = []
|
|
427
|
-
// 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
|
|
428
536
|
if (wechatAccountId) {
|
|
429
|
-
|
|
430
|
-
//
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (!this._lastUpdateSessionMap[groupId]) {
|
|
442
|
-
this._lastUpdateSessionMap[groupId] = {}
|
|
443
|
-
}
|
|
444
|
-
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
445
|
-
this._lastUpdateSessionMap[groupId][lastField] = {}
|
|
446
|
-
}
|
|
447
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
448
|
-
this._lastUpdateSessionMap[groupId][lastField][topField] = {}
|
|
449
|
-
}
|
|
450
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day]) {
|
|
451
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day] = {}
|
|
452
|
-
}
|
|
453
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
|
|
454
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
|
|
455
|
-
}
|
|
456
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push(nextData)
|
|
457
|
-
})
|
|
458
|
-
})
|
|
537
|
+
// 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
|
|
538
|
+
// 加载会话是新的在上面,老的在下面,所以一定要记录好上次分页加载的时间点
|
|
539
|
+
if (isRefreshAll) {
|
|
540
|
+
groupIds.push(nextData.wechatAccountId)
|
|
541
|
+
groupIds.push(ALL_WECHAT_ACCOUNT_ID)
|
|
542
|
+
} else {
|
|
543
|
+
groupIds.push(wechatAccountId)
|
|
544
|
+
}
|
|
545
|
+
// 先把老的删除掉
|
|
546
|
+
this._removeLastUpdateSessionMap(nextData.conversationId, wechatAccountId)
|
|
547
|
+
// 再插入新的
|
|
548
|
+
this._updateLastUpdateSessionMap([wechatAccountId], nextData)
|
|
459
549
|
} else {
|
|
460
550
|
groupIds.push(nextData.wechatAccountId)
|
|
461
551
|
groupIds.push(ALL_WECHAT_ACCOUNT_ID)
|
|
462
552
|
}
|
|
553
|
+
this.sessionMap[data.conversationId] = nextData
|
|
463
554
|
// 分组的
|
|
464
555
|
const sortFields = this.getSortField(nextData.lastMsgTime)
|
|
556
|
+
const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
|
|
465
557
|
groupIds.forEach(groupId => {
|
|
466
558
|
// 如果已经在分组里面了,就不新增了,
|
|
467
559
|
if (this._getSessionBySessionGroup(nextData.conversationId, groupId)) {
|
|
@@ -492,21 +584,62 @@ export default class ClientChatSession {
|
|
|
492
584
|
Vue.set(this.data.sessionMuteMap, nextData.wechatAccountId, {})
|
|
493
585
|
}
|
|
494
586
|
Vue.set(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId, nextData)
|
|
587
|
+
} else {
|
|
588
|
+
if (this.data.sessionMuteMap[nextData.wechatAccountId]) {
|
|
589
|
+
Vue.delete(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId)
|
|
590
|
+
}
|
|
495
591
|
}
|
|
496
592
|
// 检测一下是不是存在一样的虚拟会话,存在的话就删除
|
|
497
593
|
const virtualSessionIndex = this.data.virtualSessionData.findIndex(v => v.conversationId === nextData.conversationId)
|
|
498
594
|
if (virtualSessionIndex > -1) {
|
|
499
595
|
this.data.virtualSessionData.splice(virtualSessionIndex, 1)
|
|
500
596
|
}
|
|
501
|
-
callback && callback({
|
|
502
|
-
session: data
|
|
503
|
-
})
|
|
504
597
|
this.onAddSession && this.onAddSession({
|
|
505
|
-
|
|
598
|
+
wechatAccountId,
|
|
599
|
+
session: nextData
|
|
506
600
|
})
|
|
507
601
|
}
|
|
508
|
-
|
|
509
|
-
|
|
602
|
+
|
|
603
|
+
_updateLastUpdateSessionMap (groupIds, nextData) {
|
|
604
|
+
if (!groupIds || !groupIds.length || !nextData) {
|
|
605
|
+
return
|
|
606
|
+
}
|
|
607
|
+
// 传了wechatAccountId才记录lastMsgTime
|
|
608
|
+
const lastFields = ['lastMsgTime']
|
|
609
|
+
const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
|
|
610
|
+
groupIds.forEach(groupId => {
|
|
611
|
+
lastFields.forEach(lastField => {
|
|
612
|
+
const lastUpdateSortFields = this.getSortField(nextData[lastField])
|
|
613
|
+
if (!lastUpdateSortFields) {
|
|
614
|
+
return
|
|
615
|
+
}
|
|
616
|
+
if (!this._lastUpdateSessionMap) {
|
|
617
|
+
this._lastUpdateSessionMap = {}
|
|
618
|
+
}
|
|
619
|
+
if (!this._lastUpdateSessionMap[groupId]) {
|
|
620
|
+
this._lastUpdateSessionMap[groupId] = {}
|
|
621
|
+
}
|
|
622
|
+
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
623
|
+
this._lastUpdateSessionMap[groupId][lastField] = {}
|
|
624
|
+
}
|
|
625
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
626
|
+
this._lastUpdateSessionMap[groupId][lastField][topField] = {}
|
|
627
|
+
}
|
|
628
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day]) {
|
|
629
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day] = {}
|
|
630
|
+
}
|
|
631
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
|
|
632
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
|
|
633
|
+
}
|
|
634
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push({
|
|
635
|
+
conversationId: nextData.conversationId,
|
|
636
|
+
lastMsgTime: nextData.lastMsgTime
|
|
637
|
+
})
|
|
638
|
+
})
|
|
639
|
+
})
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
_removeSessionBySessionGroup (conversationId, wechatAccountId) {
|
|
510
643
|
if (!this.sessionMap[conversationId]) {
|
|
511
644
|
return
|
|
512
645
|
}
|
|
@@ -515,7 +648,7 @@ export default class ClientChatSession {
|
|
|
515
648
|
return
|
|
516
649
|
}
|
|
517
650
|
const topField = session.stickyOnTop ? 0 : 1 // 置顶
|
|
518
|
-
const groupIds = [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
|
|
651
|
+
const groupIds = wechatAccountId ? [wechatAccountId] : [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
|
|
519
652
|
const sortFields = this.getSortField(session.lastMsgTime)
|
|
520
653
|
groupIds.forEach(groupId => {
|
|
521
654
|
if (!this.data.sessionGroupData[groupId] || !this.data.sessionGroupData[groupId][topField]) {
|
|
@@ -523,7 +656,7 @@ export default class ClientChatSession {
|
|
|
523
656
|
}
|
|
524
657
|
const groupSession = this.data.sessionGroupData[groupId][topField]
|
|
525
658
|
if (groupSession[sortFields.day] && groupSession[sortFields.day][sortFields.milliseconds]) {
|
|
526
|
-
const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(
|
|
659
|
+
const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(session)
|
|
527
660
|
if (groupIndex >= 0) {
|
|
528
661
|
groupSession[sortFields.day][sortFields.milliseconds].splice(groupIndex, 1)
|
|
529
662
|
}
|
|
@@ -541,10 +674,19 @@ export default class ClientChatSession {
|
|
|
541
674
|
}
|
|
542
675
|
}
|
|
543
676
|
})
|
|
544
|
-
|
|
545
|
-
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
_removeLastUpdateSessionMap (conversationId, wechatAccountId) {
|
|
680
|
+
if (!this.sessionMap[conversationId]) {
|
|
681
|
+
return
|
|
682
|
+
}
|
|
683
|
+
const session = this.sessionMap[conversationId]
|
|
684
|
+
if (!session) {
|
|
685
|
+
return
|
|
546
686
|
}
|
|
547
|
-
|
|
687
|
+
let isDeleted = false
|
|
688
|
+
const lastFields = ['lastMsgTime']
|
|
689
|
+
const groupIds = wechatAccountId ? [wechatAccountId] : [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
|
|
548
690
|
groupIds.forEach(groupId => {
|
|
549
691
|
if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
|
|
550
692
|
return
|
|
@@ -553,26 +695,93 @@ export default class ClientChatSession {
|
|
|
553
695
|
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
554
696
|
return
|
|
555
697
|
}
|
|
698
|
+
const loastUpdateSortFields = this.getSortField(session[lastField])
|
|
556
699
|
Object.keys(this._lastUpdateSessionMap[groupId][lastField]).forEach(topField => {
|
|
557
700
|
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
558
701
|
return
|
|
559
702
|
}
|
|
560
|
-
const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
|
|
561
703
|
if (this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day] && this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
|
|
562
|
-
|
|
704
|
+
let index = -1
|
|
705
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].some((v, i) => {
|
|
706
|
+
if (v.conversationId === session.conversationId) {
|
|
707
|
+
index = i
|
|
708
|
+
return true
|
|
709
|
+
}
|
|
710
|
+
})
|
|
563
711
|
if (index >= 0) {
|
|
564
712
|
this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
713
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
|
|
714
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
|
|
715
|
+
}
|
|
716
|
+
if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day])) {
|
|
717
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], loastUpdateSortFields.day)
|
|
718
|
+
}
|
|
719
|
+
isDeleted = true
|
|
571
720
|
}
|
|
572
721
|
}
|
|
573
722
|
})
|
|
574
723
|
})
|
|
575
724
|
})
|
|
725
|
+
if (!isDeleted) {
|
|
726
|
+
groupIds.some(groupId => {
|
|
727
|
+
if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
|
|
728
|
+
return
|
|
729
|
+
}
|
|
730
|
+
return lastFields.some(lastField => {
|
|
731
|
+
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
732
|
+
return
|
|
733
|
+
}
|
|
734
|
+
return Object.keys(this._lastUpdateSessionMap[groupId][lastField]).some(topField => {
|
|
735
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
736
|
+
return
|
|
737
|
+
}
|
|
738
|
+
return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField]).some(day => {
|
|
739
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day]) {
|
|
740
|
+
return
|
|
741
|
+
}
|
|
742
|
+
return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField][day]).some(milliseconds => {
|
|
743
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds]) {
|
|
744
|
+
return
|
|
745
|
+
}
|
|
746
|
+
let index = -1
|
|
747
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].some((v, i) => {
|
|
748
|
+
if (v.conversationId === session.conversationId) {
|
|
749
|
+
index = i
|
|
750
|
+
return true
|
|
751
|
+
}
|
|
752
|
+
})
|
|
753
|
+
if (index >= 0) {
|
|
754
|
+
this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].splice(index, 1)
|
|
755
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].length) {
|
|
756
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][day], milliseconds)
|
|
757
|
+
}
|
|
758
|
+
if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][day])) {
|
|
759
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], day)
|
|
760
|
+
}
|
|
761
|
+
isDeleted = true
|
|
762
|
+
return true
|
|
763
|
+
}
|
|
764
|
+
})
|
|
765
|
+
})
|
|
766
|
+
})
|
|
767
|
+
})
|
|
768
|
+
})
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
removeSession (conversationId) {
|
|
773
|
+
if (!this.sessionMap[conversationId]) {
|
|
774
|
+
return
|
|
775
|
+
}
|
|
776
|
+
const session = this.sessionMap[conversationId]
|
|
777
|
+
if (!session) {
|
|
778
|
+
return
|
|
779
|
+
}
|
|
780
|
+
this._removeSessionBySessionGroup(conversationId)
|
|
781
|
+
this._removeLastUpdateSessionMap(conversationId)
|
|
782
|
+
if (this.data.sessionMuteMap[session.wechatAccountId]) {
|
|
783
|
+
delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
|
|
784
|
+
}
|
|
576
785
|
delete this.sessionMap[conversationId]
|
|
577
786
|
this.onRemoveSession && this.onRemoveSession({
|
|
578
787
|
session
|
|
@@ -637,7 +846,9 @@ export default class ClientChatSession {
|
|
|
637
846
|
return true
|
|
638
847
|
}
|
|
639
848
|
})
|
|
640
|
-
|
|
849
|
+
if (index >= 0) {
|
|
850
|
+
this.data.sessionGroupData[groupId][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
|
|
851
|
+
}
|
|
641
852
|
}
|
|
642
853
|
})
|
|
643
854
|
})
|