@aochuang/client-sdk 1.0.351 → 1.0.352
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 +6 -1
- package/components/session-select/session-select-item.vue +8 -9
- 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/url/url-miniprogram.vue +1 -5
- package/components/wechat-chat-control/voice/.DS_Store +0 -0
- package/components/wework-chat-control/channel-card/channel-card.vue +144 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +7 -2
- package/components/wework-chat-control/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/custom-expression/custom-expression.vue +2 -1
- package/components/wework-chat-control/file-url/file-url.vue +2 -5
- package/components/wework-chat-control/image/image.vue +137 -2
- package/components/wework-chat-control/index.js +9 -7
- package/components/wework-chat-control/link/.DS_Store +0 -0
- package/components/wework-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
- package/components/wework-chat-control/metting/meeting-video.svg +4 -0
- package/components/wework-chat-control/metting/metting.vue +181 -0
- package/components/wework-chat-control/text/text.vue +23 -3
- package/components/wework-chat-control/url/url-channel-live.vue +53 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +6 -7
- package/components/wework-chat-control/url/url.vue +26 -2
- package/components/wework-chat-control/util.js +17 -8
- package/components/wework-chat-control/video/.DS_Store +0 -0
- package/components/wework-chat-control/video/video.vue +10 -2
- package/components/wework-chat-control/voice/voice.vue +1 -1
- package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
- package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
- package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
- package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +73 -0
- package/components/wework-chat-panel/chat-panel-item.vue +25 -41
- package/components/wework-chat-panel/chat-panel.vue +95 -12
- package/package.json +10 -3
- package/services/client-chat/client-chat-wechat/client-chat-session.js +92 -196
- package/services/client-chat/client-chat-wechat/client-chat.js +33 -20
- package/services/client-chat/client-chat-wework/client-chat-concats.js +81 -17
- package/services/client-chat/client-chat-wework/client-chat-message.js +46 -6
- package/services/client-chat/client-chat-wework/client-chat-session.js +50 -2
- package/services/client-chat/client-chat-wework/client-chat-socket.js +9 -1
- package/services/client-chat/client-chat-wework/client-chat.js +283 -13
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
- package/uni-common/account-portray/account-portray.vue +0 -51
- package/uni-common/account-select/account-select-item.vue +0 -172
- package/uni-common/account-select/account-select.vue +0 -252
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
- package/uni-common/friend-avatar/default.svg +0 -1
- package/uni-common/friend-avatar/friend-avatar.vue +0 -27
- package/uni-common/friend-avatar/index.js +0 -3
- package/uni-common/friend-loader/friend-loader.vue +0 -53
- package/uni-common/friend-portray/friend-portray.vue +0 -56
- package/uni-common/group-avatar/default.svg +0 -1
- package/uni-common/group-avatar/group-avatar.vue +0 -18
- package/uni-common/group-avatar/index.js +0 -3
- package/uni-common/room-avatar/default.svg +0 -6
- package/uni-common/room-avatar/index.js +0 -3
- package/uni-common/room-avatar/room-avatar.vue +0 -27
- package/uni-common/room-loader/room-loader.vue +0 -53
- package/uni-common/room-portray/room-portray.vue +0 -56
- package/uni-components/chat-control/calling/calling.vue +0 -91
- package/uni-components/chat-control/calling/phone-fill.svg +0 -1
- package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
- package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
- package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
- package/uni-components/chat-control/chat-control.vue +0 -218
- package/uni-components/chat-control/company-card/company-card.vue +0 -123
- package/uni-components/chat-control/const.js +0 -28
- package/uni-components/chat-control/expression/expression.vue +0 -41
- package/uni-components/chat-control/image/image.vue +0 -68
- package/uni-components/chat-control/index.js +0 -89
- package/uni-components/chat-control/location/location.vue +0 -110
- package/uni-components/chat-control/member-change/member-change.vue +0 -32
- package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
- package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
- package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
- package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
- package/uni-components/chat-control/share-card/share-card.vue +0 -101
- package/uni-components/chat-control/system/system.vue +0 -69
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
- package/uni-components/chat-control/system-text/system-text.vue +0 -32
- package/uni-components/chat-control/text/text.vue +0 -67
- package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
- package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
- package/uni-components/chat-control/transfer/transfer.vue +0 -80
- package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
- package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url/icons/index.js +0 -24
- package/uni-components/chat-control/url/miniprogram.svg +0 -1
- package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
- package/uni-components/chat-control/url/url.vue +0 -306
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/index.js +0 -24
- package/uni-components/chat-control/url-new/url-new.vue +0 -110
- package/uni-components/chat-control/utils.js +0 -12
- package/uni-components/chat-control/video/video.vue +0 -156
- package/uni-components/chat-control/voice/voice.vue +0 -166
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
- package/uni-components/chat-editor/chat-editor.vue +0 -257
- package/uni-components/chat-editor/index.js +0 -10
- package/uni-components/chat-editor/util.js +0 -65
- package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
- package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
- package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
- package/uni-components/chat-panel/chat-panel.vue +0 -227
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
- package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
|
@@ -228,40 +228,50 @@ export default class ClientChatSession {
|
|
|
228
228
|
})
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
getSession (sessionId, serializeMethod) {
|
|
231
|
+
getSession (sessionId, serializeMethod, callback = null, isCache = true) {
|
|
232
|
+
if (typeof callback === 'boolean') {
|
|
233
|
+
isCache = callback
|
|
234
|
+
callback = null
|
|
235
|
+
}
|
|
232
236
|
if (this.sessionMap[sessionId]) {
|
|
233
237
|
return Promise.resolve({
|
|
234
238
|
data: this.sessionMap[sessionId]
|
|
235
239
|
})
|
|
236
240
|
}
|
|
237
241
|
// 这里需要轮询从后端获取会话,后端会话更新和创建是异步的,所以要多轮训请求几次
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (serializeMethod) {
|
|
251
|
-
rs = serializeMethod(rs)
|
|
252
|
-
}
|
|
242
|
+
if (this.pollRequestMap[sessionId]) {
|
|
243
|
+
// 因为有的地方要复用缓存,有的地方不能缓存,比如onAddMessagSuccess的时候不能缓存
|
|
244
|
+
if (isCache) {
|
|
245
|
+
return this.pollRequestMap[sessionId].ps
|
|
246
|
+
} else {
|
|
247
|
+
this.pollRequestMap[sessionId].stop()
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const pollRequest = createPollRequest(({ done, fail }) => {
|
|
251
|
+
return this.getSessionMethod({
|
|
252
|
+
id: sessionId
|
|
253
|
+
}).then((rs) => {
|
|
253
254
|
if (rs.data) {
|
|
254
|
-
|
|
255
|
-
return rs
|
|
256
|
-
} else {
|
|
257
|
-
return Promise.reject('未找到会话' + sessionId)
|
|
258
|
-
}
|
|
259
|
-
}).finally(() => {
|
|
260
|
-
if (this.pollRequestMap[sessionId] === pollRequest) {
|
|
261
|
-
delete this.pollRequestMap[sessionId]
|
|
255
|
+
done(rs)
|
|
262
256
|
}
|
|
263
257
|
})
|
|
264
|
-
}
|
|
258
|
+
})
|
|
259
|
+
this.pollRequestMap[sessionId] = pollRequest
|
|
260
|
+
this.pollRequestMap[sessionId].ps = pollRequest.start().then(rs => {
|
|
261
|
+
if (serializeMethod) {
|
|
262
|
+
rs = serializeMethod(rs)
|
|
263
|
+
}
|
|
264
|
+
if (rs.data) {
|
|
265
|
+
this.addSession(rs.data, null, callback)
|
|
266
|
+
return rs
|
|
267
|
+
} else {
|
|
268
|
+
return Promise.reject('未找到会话' + sessionId)
|
|
269
|
+
}
|
|
270
|
+
}).finally(() => {
|
|
271
|
+
if (this.pollRequestMap[sessionId] === pollRequest) {
|
|
272
|
+
delete this.pollRequestMap[sessionId]
|
|
273
|
+
}
|
|
274
|
+
})
|
|
265
275
|
return this.pollRequestMap[sessionId].ps
|
|
266
276
|
}
|
|
267
277
|
|
|
@@ -387,7 +397,7 @@ export default class ClientChatSession {
|
|
|
387
397
|
* "wechatAccountId": "2a39a725814acf07502299ab2285fff8d44377f5"
|
|
388
398
|
* }
|
|
389
399
|
*/
|
|
390
|
-
addSession (data, wechatAccountId) {
|
|
400
|
+
addSession (data, wechatAccountId, callback) {
|
|
391
401
|
if (!data || !data.conversationId) {
|
|
392
402
|
throw new Error('缺少必须参数conversationId')
|
|
393
403
|
}
|
|
@@ -402,53 +412,56 @@ export default class ClientChatSession {
|
|
|
402
412
|
}) === false) {
|
|
403
413
|
return
|
|
404
414
|
}
|
|
405
|
-
|
|
406
|
-
throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
|
|
407
|
-
}
|
|
408
|
-
let nextData = null
|
|
409
|
-
let isRefreshAll = false
|
|
410
|
-
let groupIds = []
|
|
415
|
+
let nextData = data
|
|
411
416
|
// 如果会话已经存在,那么取已经存在的,以后有需要可以用data更新已经存在的会话,保持引用关系
|
|
412
|
-
// 一般比较容易出现,例如all的时候,分配的时候有可能会出现,例如以前的会话没有正确删除,后面有分配过来了
|
|
413
417
|
if (this.sessionMap[data.conversationId]) {
|
|
414
|
-
// 如果会话比较老,就不更新属性
|
|
415
|
-
if (this.sessionMap[data.conversationId].lastMsgTime && data.lastMsgTime && this.sessionMap[data.conversationId].lastMsgTime <= data.lastMsgTime) {
|
|
416
|
-
// 先删后插
|
|
417
|
-
this._removeSessionBySessionGroup(this.sessionMap[data.conversationId].conversationId)
|
|
418
|
-
// 更新属性
|
|
419
|
-
Object.keys(data).forEach(k => {
|
|
420
|
-
Vue.set(this.sessionMap[data.conversationId], k, data[k])
|
|
421
|
-
})
|
|
422
|
-
}
|
|
423
418
|
nextData = this.sessionMap[data.conversationId]
|
|
424
|
-
isRefreshAll = true
|
|
425
419
|
} else {
|
|
426
|
-
|
|
420
|
+
this.sessionMap[data.conversationId] = nextData
|
|
427
421
|
}
|
|
428
|
-
|
|
429
|
-
|
|
422
|
+
const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
|
|
423
|
+
if (wechatAccountId && wechatAccountId !== ALL_WECHAT_ACCOUNT_ID && nextData.wechatAccountId !== wechatAccountId) {
|
|
424
|
+
throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
|
|
430
425
|
}
|
|
426
|
+
const groupIds = []
|
|
427
|
+
// 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
|
|
431
428
|
if (wechatAccountId) {
|
|
432
|
-
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
429
|
+
groupIds.push(wechatAccountId)
|
|
430
|
+
// 传了wechatAccountId才记录lastMsgTime和lastUpdateTime
|
|
431
|
+
const lastFields = ['lastMsgTime', 'lastUpdateTime']
|
|
432
|
+
groupIds.forEach(groupId => {
|
|
433
|
+
lastFields.forEach(lastField => {
|
|
434
|
+
const lastUpdateSortFields = this.getSortField(nextData[lastField])
|
|
435
|
+
if (!lastUpdateSortFields) {
|
|
436
|
+
return
|
|
437
|
+
}
|
|
438
|
+
if (!this._lastUpdateSessionMap) {
|
|
439
|
+
this._lastUpdateSessionMap = {}
|
|
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
|
+
})
|
|
444
459
|
} else {
|
|
445
460
|
groupIds.push(nextData.wechatAccountId)
|
|
446
461
|
groupIds.push(ALL_WECHAT_ACCOUNT_ID)
|
|
447
462
|
}
|
|
448
|
-
this.sessionMap[data.conversationId] = nextData
|
|
449
463
|
// 分组的
|
|
450
464
|
const sortFields = this.getSortField(nextData.lastMsgTime)
|
|
451
|
-
const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
|
|
452
465
|
groupIds.forEach(groupId => {
|
|
453
466
|
// 如果已经在分组里面了,就不新增了,
|
|
454
467
|
if (this._getSessionBySessionGroup(nextData.conversationId, groupId)) {
|
|
@@ -479,62 +492,21 @@ export default class ClientChatSession {
|
|
|
479
492
|
Vue.set(this.data.sessionMuteMap, nextData.wechatAccountId, {})
|
|
480
493
|
}
|
|
481
494
|
Vue.set(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId, nextData)
|
|
482
|
-
} else {
|
|
483
|
-
if (this.data.sessionMuteMap[nextData.wechatAccountId]) {
|
|
484
|
-
Vue.delete(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId)
|
|
485
|
-
}
|
|
486
495
|
}
|
|
487
496
|
// 检测一下是不是存在一样的虚拟会话,存在的话就删除
|
|
488
497
|
const virtualSessionIndex = this.data.virtualSessionData.findIndex(v => v.conversationId === nextData.conversationId)
|
|
489
498
|
if (virtualSessionIndex > -1) {
|
|
490
499
|
this.data.virtualSessionData.splice(virtualSessionIndex, 1)
|
|
491
500
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
session: nextData
|
|
501
|
+
callback && callback({
|
|
502
|
+
session: data
|
|
495
503
|
})
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
_updateLastUpdateSessionMap (groupIds, nextData) {
|
|
499
|
-
if (!groupIds || !groupIds.length || !nextData) {
|
|
500
|
-
return
|
|
501
|
-
}
|
|
502
|
-
// 传了wechatAccountId才记录lastMsgTime
|
|
503
|
-
const lastFields = ['lastMsgTime']
|
|
504
|
-
const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
|
|
505
|
-
groupIds.forEach(groupId => {
|
|
506
|
-
lastFields.forEach(lastField => {
|
|
507
|
-
const lastUpdateSortFields = this.getSortField(nextData[lastField])
|
|
508
|
-
if (!lastUpdateSortFields) {
|
|
509
|
-
return
|
|
510
|
-
}
|
|
511
|
-
if (!this._lastUpdateSessionMap) {
|
|
512
|
-
this._lastUpdateSessionMap = {}
|
|
513
|
-
}
|
|
514
|
-
if (!this._lastUpdateSessionMap[groupId]) {
|
|
515
|
-
this._lastUpdateSessionMap[groupId] = {}
|
|
516
|
-
}
|
|
517
|
-
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
518
|
-
this._lastUpdateSessionMap[groupId][lastField] = {}
|
|
519
|
-
}
|
|
520
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
521
|
-
this._lastUpdateSessionMap[groupId][lastField][topField] = {}
|
|
522
|
-
}
|
|
523
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day]) {
|
|
524
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day] = {}
|
|
525
|
-
}
|
|
526
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
|
|
527
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
|
|
528
|
-
}
|
|
529
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push({
|
|
530
|
-
conversationId: nextData.conversationId,
|
|
531
|
-
lastMsgTime: nextData.lastMsgTime
|
|
532
|
-
})
|
|
533
|
-
})
|
|
504
|
+
this.onAddSession && this.onAddSession({
|
|
505
|
+
session: data
|
|
534
506
|
})
|
|
535
507
|
}
|
|
536
|
-
|
|
537
|
-
|
|
508
|
+
|
|
509
|
+
removeSession (conversationId) {
|
|
538
510
|
if (!this.sessionMap[conversationId]) {
|
|
539
511
|
return
|
|
540
512
|
}
|
|
@@ -543,7 +515,7 @@ export default class ClientChatSession {
|
|
|
543
515
|
return
|
|
544
516
|
}
|
|
545
517
|
const topField = session.stickyOnTop ? 0 : 1 // 置顶
|
|
546
|
-
const groupIds =
|
|
518
|
+
const groupIds = [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
|
|
547
519
|
const sortFields = this.getSortField(session.lastMsgTime)
|
|
548
520
|
groupIds.forEach(groupId => {
|
|
549
521
|
if (!this.data.sessionGroupData[groupId] || !this.data.sessionGroupData[groupId][topField]) {
|
|
@@ -551,7 +523,7 @@ export default class ClientChatSession {
|
|
|
551
523
|
}
|
|
552
524
|
const groupSession = this.data.sessionGroupData[groupId][topField]
|
|
553
525
|
if (groupSession[sortFields.day] && groupSession[sortFields.day][sortFields.milliseconds]) {
|
|
554
|
-
const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(
|
|
526
|
+
const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(this.sessionMap[conversationId])
|
|
555
527
|
if (groupIndex >= 0) {
|
|
556
528
|
groupSession[sortFields.day][sortFields.milliseconds].splice(groupIndex, 1)
|
|
557
529
|
}
|
|
@@ -569,19 +541,10 @@ export default class ClientChatSession {
|
|
|
569
541
|
}
|
|
570
542
|
}
|
|
571
543
|
})
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
_removeLastUpdateSessionMap (conversationId, wechatAccountId) {
|
|
575
|
-
if (!this.sessionMap[conversationId]) {
|
|
576
|
-
return
|
|
577
|
-
}
|
|
578
|
-
const session = this.sessionMap[conversationId]
|
|
579
|
-
if (!session) {
|
|
580
|
-
return
|
|
544
|
+
if (this.data.sessionMuteMap[session.wechatAccountId]) {
|
|
545
|
+
delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
|
|
581
546
|
}
|
|
582
|
-
|
|
583
|
-
const lastFields = ['lastMsgTime']
|
|
584
|
-
const groupIds = wechatAccountId ? [wechatAccountId] : [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
|
|
547
|
+
const lastFields = ['lastMsgTime', 'lastUpdateTime']
|
|
585
548
|
groupIds.forEach(groupId => {
|
|
586
549
|
if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
|
|
587
550
|
return
|
|
@@ -590,93 +553,26 @@ export default class ClientChatSession {
|
|
|
590
553
|
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
591
554
|
return
|
|
592
555
|
}
|
|
593
|
-
const loastUpdateSortFields = this.getSortField(session[lastField])
|
|
594
556
|
Object.keys(this._lastUpdateSessionMap[groupId][lastField]).forEach(topField => {
|
|
595
557
|
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
596
558
|
return
|
|
597
559
|
}
|
|
560
|
+
const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
|
|
598
561
|
if (this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day] && this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
|
|
599
|
-
|
|
600
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].some((v, i) => {
|
|
601
|
-
if (v.conversationId === session.conversationId) {
|
|
602
|
-
index = i
|
|
603
|
-
return true
|
|
604
|
-
}
|
|
605
|
-
})
|
|
562
|
+
const index = this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].indexOf(session)
|
|
606
563
|
if (index >= 0) {
|
|
607
564
|
this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
isDeleted = true
|
|
565
|
+
}
|
|
566
|
+
if (!this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
|
|
567
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
|
|
568
|
+
}
|
|
569
|
+
if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day])) {
|
|
570
|
+
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], loastUpdateSortFields.day)
|
|
615
571
|
}
|
|
616
572
|
}
|
|
617
573
|
})
|
|
618
574
|
})
|
|
619
575
|
})
|
|
620
|
-
if (!isDeleted) {
|
|
621
|
-
groupIds.some(groupId => {
|
|
622
|
-
if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
|
|
623
|
-
return
|
|
624
|
-
}
|
|
625
|
-
return lastFields.some(lastField => {
|
|
626
|
-
if (!this._lastUpdateSessionMap[groupId][lastField]) {
|
|
627
|
-
return
|
|
628
|
-
}
|
|
629
|
-
return Object.keys(this._lastUpdateSessionMap[groupId][lastField]).some(topField => {
|
|
630
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
|
|
631
|
-
return
|
|
632
|
-
}
|
|
633
|
-
return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField]).some(day => {
|
|
634
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day]) {
|
|
635
|
-
return
|
|
636
|
-
}
|
|
637
|
-
return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField][day]).some(milliseconds => {
|
|
638
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds]) {
|
|
639
|
-
return
|
|
640
|
-
}
|
|
641
|
-
let index = -1
|
|
642
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].some((v, i) => {
|
|
643
|
-
if (v.conversationId === session.conversationId) {
|
|
644
|
-
index = i
|
|
645
|
-
return true
|
|
646
|
-
}
|
|
647
|
-
})
|
|
648
|
-
if (index >= 0) {
|
|
649
|
-
this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].splice(index, 1)
|
|
650
|
-
if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].length) {
|
|
651
|
-
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][day], milliseconds)
|
|
652
|
-
}
|
|
653
|
-
if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][day])) {
|
|
654
|
-
Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], day)
|
|
655
|
-
}
|
|
656
|
-
isDeleted = true
|
|
657
|
-
return true
|
|
658
|
-
}
|
|
659
|
-
})
|
|
660
|
-
})
|
|
661
|
-
})
|
|
662
|
-
})
|
|
663
|
-
})
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
removeSession (conversationId) {
|
|
668
|
-
if (!this.sessionMap[conversationId]) {
|
|
669
|
-
return
|
|
670
|
-
}
|
|
671
|
-
const session = this.sessionMap[conversationId]
|
|
672
|
-
if (!session) {
|
|
673
|
-
return
|
|
674
|
-
}
|
|
675
|
-
this._removeSessionBySessionGroup(conversationId)
|
|
676
|
-
this._removeLastUpdateSessionMap(conversationId)
|
|
677
|
-
if (this.data.sessionMuteMap[session.wechatAccountId]) {
|
|
678
|
-
delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
|
|
679
|
-
}
|
|
680
576
|
delete this.sessionMap[conversationId]
|
|
681
577
|
this.onRemoveSession && this.onRemoveSession({
|
|
682
578
|
session
|
|
@@ -115,24 +115,7 @@ class ClientChat {
|
|
|
115
115
|
const mergeSessionCommonOptions = (options, instance) => {
|
|
116
116
|
let updateSessioning = false
|
|
117
117
|
let removeSessioning = false
|
|
118
|
-
options.onAddSession = ({ session
|
|
119
|
-
// 不是来源于分页的时候,没有wechatAccountId就是代表不是走的分页增加的会话,一般为获取新消息或则分配的会话
|
|
120
|
-
if (!wechatAccountId && instance === this.session) {
|
|
121
|
-
// 更新账号未读消息数量
|
|
122
|
-
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
123
|
-
if (session.mute) {
|
|
124
|
-
return {
|
|
125
|
-
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
126
|
-
muteNum: (unreadMessageMuteNum || 0) + (session.unreadMsgCount || 0)
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
return {
|
|
130
|
-
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
131
|
-
muteNum: unreadMessageMuteNum
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
}
|
|
118
|
+
options.onAddSession = ({ session }) => {
|
|
136
119
|
// 同步未读会话
|
|
137
120
|
if (instance !== this.sessionUnread && session.unreadMsgCount > 0) {
|
|
138
121
|
const localSession = this.sessionUnread.findSession((localSession) => localSession.conversationId === session.conversationId)
|
|
@@ -440,7 +423,22 @@ class ClientChat {
|
|
|
440
423
|
rs.data.lastUpdateTime = data.updateDate
|
|
441
424
|
}
|
|
442
425
|
return rs
|
|
443
|
-
}
|
|
426
|
+
}, ({ session }) => {
|
|
427
|
+
// 更新账号未读消息数量
|
|
428
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
429
|
+
if (session.mute) {
|
|
430
|
+
return {
|
|
431
|
+
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
432
|
+
muteNum: (unreadMessageMuteNum || 0) + (session.unreadMsgCount || 0)
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
return {
|
|
436
|
+
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
437
|
+
muteNum: unreadMessageMuteNum
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
}, false).then((rs => {
|
|
444
442
|
// 前面更新未读消息数量只是处理会话的时候,因为getSession是异步的,会导致addMessage多次执行到这里,不会倒下面更新会话的逻辑
|
|
445
443
|
// 比如连续发了3条消息,然后getSession后端返回可能只会返回2条未读数,所以这里还需要补偿一下
|
|
446
444
|
const session = rs.data || {}
|
|
@@ -596,7 +594,22 @@ class ClientChat {
|
|
|
596
594
|
rs.data.lastAtMsgContent = appendLastAtMsgContent(rs.data.lastAtMsgContent, atMessage)
|
|
597
595
|
}
|
|
598
596
|
return rs
|
|
599
|
-
}
|
|
597
|
+
}, ({ session }) => {
|
|
598
|
+
// 更新账号未读消息数量
|
|
599
|
+
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
600
|
+
if (session.mute) {
|
|
601
|
+
return {
|
|
602
|
+
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
603
|
+
muteNum: (unreadMessageMuteNum || 0) + (session.unreadMsgCount || 0)
|
|
604
|
+
}
|
|
605
|
+
} else {
|
|
606
|
+
return {
|
|
607
|
+
num: (unreadMesasgeNum || 0) + (session.unreadMsgCount || 0),
|
|
608
|
+
muteNum: unreadMessageMuteNum
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
})
|
|
612
|
+
}, false).then(rs => {
|
|
600
613
|
// 前面更新未读消息数量只是处理会话的时候,因为getSession是异步的,会导致addMessage多次执行到这里,不会倒下面更新会话的逻辑
|
|
601
614
|
// 比如连续发了3条消息,然后getSession后端返回可能只会返回2条未读数,所以这里还需要补偿一下
|
|
602
615
|
const session = rs.data || {}
|
|
@@ -126,11 +126,7 @@ export default class ClientChatContacts {
|
|
|
126
126
|
*/
|
|
127
127
|
roomBindMemberMap: {},
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
* 标记通讯录是否修改了
|
|
131
|
-
* 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
|
|
132
|
-
*/
|
|
133
|
-
isModify: false
|
|
129
|
+
modifiedAccountMap: {}
|
|
134
130
|
})
|
|
135
131
|
|
|
136
132
|
friendMap = {}
|
|
@@ -237,10 +233,6 @@ export default class ClientChatContacts {
|
|
|
237
233
|
return this.data.roomGroupData
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
get isModify () {
|
|
241
|
-
return this.data.isModify
|
|
242
|
-
}
|
|
243
|
-
|
|
244
236
|
setRoomGroup (data) {
|
|
245
237
|
this.data.roomGroupData = []
|
|
246
238
|
if (data && data.length) {
|
|
@@ -491,10 +483,10 @@ export default class ClientChatContacts {
|
|
|
491
483
|
}
|
|
492
484
|
}
|
|
493
485
|
const qwAccountId = this.roomMap[id].qwAccountId
|
|
494
|
-
if (qwAccountId && this.data.
|
|
495
|
-
const bindIndex = this.data.
|
|
486
|
+
if (qwAccountId && this.data.accountBindRoomMap[qwAccountId] && this.data.accountBindRoomMap[qwAccountId][groupId]) {
|
|
487
|
+
const bindIndex = this.data.accountBindRoomMap[qwAccountId][groupId].indexOf(this.roomMap[id])
|
|
496
488
|
if (bindIndex >= 0) {
|
|
497
|
-
this.data.
|
|
489
|
+
this.data.accountBindRoomMap[qwAccountId][groupId].splice(bindIndex, 1)
|
|
498
490
|
}
|
|
499
491
|
}
|
|
500
492
|
})
|
|
@@ -628,6 +620,37 @@ export default class ClientChatContacts {
|
|
|
628
620
|
return rs
|
|
629
621
|
})
|
|
630
622
|
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* 强制从服务端刷新好友资料,绕过本地缓存。
|
|
626
|
+
*/
|
|
627
|
+
refreshFriend (friendId) {
|
|
628
|
+
if (!friendId) {
|
|
629
|
+
return Promise.reject('缺少好友id')
|
|
630
|
+
}
|
|
631
|
+
if (!this.getContactsFriendMethod) {
|
|
632
|
+
return Promise.reject(new Error('getContactsFriendMethod未定义'))
|
|
633
|
+
}
|
|
634
|
+
return this.getContactsFriendMethod({
|
|
635
|
+
id: friendId
|
|
636
|
+
}).then(rs => {
|
|
637
|
+
if (!rs || !rs.data) {
|
|
638
|
+
return Promise.reject('未找到好友' + friendId)
|
|
639
|
+
}
|
|
640
|
+
if (this.friendMap[friendId]) {
|
|
641
|
+
const nextKeys = Object.keys(rs.data)
|
|
642
|
+
Object.keys(this.friendMap[friendId]).forEach(key => {
|
|
643
|
+
if (!nextKeys.includes(key)) {
|
|
644
|
+
Vue.delete(this.friendMap[friendId], key)
|
|
645
|
+
}
|
|
646
|
+
})
|
|
647
|
+
this.updateFriend(friendId, rs.data)
|
|
648
|
+
} else {
|
|
649
|
+
this.addFriend(rs.data)
|
|
650
|
+
}
|
|
651
|
+
return rs
|
|
652
|
+
})
|
|
653
|
+
}
|
|
631
654
|
|
|
632
655
|
setRoomMemberData (roomId, data) {
|
|
633
656
|
if (!roomId) {
|
|
@@ -738,12 +761,52 @@ export default class ClientChatContacts {
|
|
|
738
761
|
})
|
|
739
762
|
}
|
|
740
763
|
|
|
741
|
-
|
|
742
|
-
|
|
764
|
+
refreshRoom (id) {
|
|
765
|
+
if (!id) {
|
|
766
|
+
return Promise.reject('缺少群id')
|
|
767
|
+
}
|
|
768
|
+
if (!this.getContactsRoomMethod) {
|
|
769
|
+
return Promise.reject(new Error('getContactsRoomMethod未定义'))
|
|
770
|
+
}
|
|
771
|
+
return this.getContactsRoomMethod({
|
|
772
|
+
id
|
|
773
|
+
}).then(rs => {
|
|
774
|
+
if (!rs || !rs.data) {
|
|
775
|
+
return Promise.reject('未找到群' + id)
|
|
776
|
+
}
|
|
777
|
+
const localRoom = this.roomMap[id]
|
|
778
|
+
if (localRoom) {
|
|
779
|
+
this.removeRoom(id)
|
|
780
|
+
const nextKeys = Object.keys(rs.data)
|
|
781
|
+
Object.keys(localRoom).forEach(key => {
|
|
782
|
+
if (!nextKeys.includes(key)) {
|
|
783
|
+
Vue.delete(localRoom, key)
|
|
784
|
+
}
|
|
785
|
+
})
|
|
786
|
+
Object.keys(rs.data).forEach(key => {
|
|
787
|
+
Vue.set(localRoom, key, rs.data[key])
|
|
788
|
+
})
|
|
789
|
+
}
|
|
790
|
+
this.addRoom(localRoom || rs.data)
|
|
791
|
+
return rs
|
|
792
|
+
})
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
isModify (qwAccountId) {
|
|
796
|
+
return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
markModify (qwAccountIds) {
|
|
800
|
+
const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
|
|
801
|
+
ids.filter(Boolean).forEach(id => {
|
|
802
|
+
Vue.set(this.data.modifiedAccountMap, id, true)
|
|
803
|
+
})
|
|
743
804
|
}
|
|
744
805
|
|
|
745
|
-
unmarkModify () {
|
|
746
|
-
|
|
806
|
+
unmarkModify (qwAccountId) {
|
|
807
|
+
if (qwAccountId) {
|
|
808
|
+
Vue.delete(this.data.modifiedAccountMap, qwAccountId)
|
|
809
|
+
}
|
|
747
810
|
}
|
|
748
811
|
|
|
749
812
|
reset () {
|
|
@@ -758,6 +821,7 @@ export default class ClientChatContacts {
|
|
|
758
821
|
this.data.groupBindRoomMap = {}
|
|
759
822
|
this.data.accountBindFriendMap = {}
|
|
760
823
|
this.data.accountBindRoomMap = {}
|
|
824
|
+
this.data.modifiedAccountMap = {}
|
|
761
825
|
this._cacheFriendGroupCountMap = null
|
|
762
826
|
this._cacheRoomGroupCountMap = null
|
|
763
827
|
if (this.cancelConnectRequest) {
|
|
@@ -769,4 +833,4 @@ export default class ClientChatContacts {
|
|
|
769
833
|
this.cancelRefreshRequest = null
|
|
770
834
|
}
|
|
771
835
|
}
|
|
772
|
-
}
|
|
836
|
+
}
|