@aochuang/client-sdk 1.0.348 → 1.0.350

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.
Files changed (145) hide show
  1. package/components/index.js +1 -6
  2. package/components/session-select/session-select-item.vue +9 -8
  3. package/components/wechat-chat-control/url/url-miniprogram.vue +5 -1
  4. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  5. package/components/wework-chat-control/file-url/file-url.vue +5 -2
  6. package/components/wework-chat-control/image/image.vue +2 -137
  7. package/components/wework-chat-control/index.js +6 -6
  8. package/components/wework-chat-control/text/text.vue +3 -22
  9. package/components/wework-chat-control/util.js +6 -12
  10. package/components/wework-chat-control/video/video.vue +2 -10
  11. package/components/wework-chat-control/voice/voice.vue +1 -1
  12. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
  13. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
  14. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
  15. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
  16. package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
  17. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
  18. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
  19. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
  20. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
  21. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
  22. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
  23. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
  24. package/components/wework-chat-panel/chat-panel-item.vue +35 -12
  25. package/components/wework-chat-panel/chat-panel.vue +12 -95
  26. package/package.json +3 -10
  27. package/services/client-chat/client-chat-wechat/client-chat-session.js +170 -54
  28. package/services/client-chat/client-chat-wework/client-chat-concats.js +17 -81
  29. package/services/client-chat/client-chat-wework/client-chat-message.js +6 -46
  30. package/services/client-chat/client-chat-wework/client-chat-session.js +2 -50
  31. package/services/client-chat/client-chat-wework/client-chat-socket.js +1 -9
  32. package/services/client-chat/client-chat-wework/client-chat.js +13 -283
  33. package/services/client-chat/client-chat-wework/utils.js +5 -5
  34. package/uni-common/account-portray/account-portray.vue +51 -0
  35. package/uni-common/account-select/account-select-item.vue +172 -0
  36. package/uni-common/account-select/account-select.vue +252 -0
  37. package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
  38. package/uni-common/friend-avatar/default.svg +1 -0
  39. package/uni-common/friend-avatar/friend-avatar.vue +27 -0
  40. package/uni-common/friend-avatar/index.js +3 -0
  41. package/uni-common/friend-loader/friend-loader.vue +53 -0
  42. package/uni-common/friend-portray/friend-portray.vue +56 -0
  43. package/uni-common/group-avatar/default.svg +1 -0
  44. package/uni-common/group-avatar/group-avatar.vue +18 -0
  45. package/uni-common/group-avatar/index.js +3 -0
  46. package/uni-common/room-avatar/default.svg +6 -0
  47. package/uni-common/room-avatar/index.js +3 -0
  48. package/uni-common/room-avatar/room-avatar.vue +27 -0
  49. package/uni-common/room-loader/room-loader.vue +53 -0
  50. package/uni-common/room-portray/room-portray.vue +56 -0
  51. package/uni-components/chat-control/calling/calling.vue +91 -0
  52. package/uni-components/chat-control/calling/phone-fill.svg +1 -0
  53. package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
  54. package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
  55. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
  56. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
  57. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
  58. package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
  59. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
  60. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
  61. package/{components/wework-chat-control/wework-chat-control-config.vue → uni-components/chat-control/chat-control-config.vue} +13 -16
  62. package/uni-components/chat-control/chat-control.vue +218 -0
  63. package/uni-components/chat-control/company-card/company-card.vue +123 -0
  64. package/uni-components/chat-control/const.js +28 -0
  65. package/uni-components/chat-control/expression/expression.vue +41 -0
  66. package/uni-components/chat-control/image/image.vue +68 -0
  67. package/uni-components/chat-control/index.js +89 -0
  68. package/uni-components/chat-control/location/location.vue +110 -0
  69. package/uni-components/chat-control/member-change/member-change.vue +32 -0
  70. package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
  71. package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
  72. package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
  73. package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
  74. package/uni-components/chat-control/share-card/share-card.vue +101 -0
  75. package/uni-components/chat-control/system/system.vue +69 -0
  76. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
  77. package/uni-components/chat-control/system-text/system-text.vue +32 -0
  78. package/uni-components/chat-control/text/text.vue +67 -0
  79. package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
  80. package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
  81. package/uni-components/chat-control/transfer/transfer.vue +80 -0
  82. package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
  83. package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
  84. package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
  85. package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
  86. package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
  87. package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
  88. package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
  89. package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
  90. package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
  91. package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
  92. package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
  93. package/uni-components/chat-control/url/icons/index.js +24 -0
  94. package/uni-components/chat-control/url/miniprogram.svg +1 -0
  95. package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
  96. package/uni-components/chat-control/url/url.vue +306 -0
  97. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
  98. package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
  99. package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
  100. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
  101. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
  102. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
  103. package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
  104. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
  105. package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
  106. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
  107. package/uni-components/chat-control/url-new/icons/index.js +24 -0
  108. package/uni-components/chat-control/url-new/url-new.vue +110 -0
  109. package/uni-components/chat-control/utils.js +12 -0
  110. package/uni-components/chat-control/video/video.vue +156 -0
  111. package/uni-components/chat-control/voice/voice.vue +166 -0
  112. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
  113. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
  114. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
  115. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
  116. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
  117. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
  118. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
  119. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
  120. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
  121. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
  122. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
  123. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
  124. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
  125. package/uni-components/chat-editor/chat-editor.vue +257 -0
  126. package/uni-components/chat-editor/index.js +10 -0
  127. package/uni-components/chat-editor/util.js +65 -0
  128. package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
  129. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
  130. package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
  131. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
  132. package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
  133. package/uni-components/chat-panel/chat-panel.vue +227 -0
  134. package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
  135. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
  136. package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
  137. package/components/wechat-chat-control/.DS_Store +0 -0
  138. package/components/wechat-chat-control/transfer/.DS_Store +0 -0
  139. package/components/wechat-chat-control/url/.DS_Store +0 -0
  140. package/components/wechat-chat-control/voice/.DS_Store +0 -0
  141. package/components/wework-chat-control/link/.DS_Store +0 -0
  142. package/components/wework-chat-control/video/.DS_Store +0 -0
  143. package/components/wework-chat-control/wework-chat-control-config-item.vue +0 -24
  144. package/components/wework-chat-control/wework-chat-control-config-msg.vue +0 -25
  145. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +0 -73
@@ -412,56 +412,53 @@ export default class ClientChatSession {
412
412
  }) === false) {
413
413
  return
414
414
  }
415
- let nextData = data
415
+ if (wechatAccountId && wechatAccountId !== ALL_WECHAT_ACCOUNT_ID && data.wechatAccountId !== wechatAccountId) {
416
+ throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
417
+ }
418
+ let nextData = null
419
+ let isRefreshAll = false
420
+ let groupIds = []
416
421
  // 如果会话已经存在,那么取已经存在的,以后有需要可以用data更新已经存在的会话,保持引用关系
422
+ // 一般比较容易出现,例如all的时候,分配的时候有可能会出现,例如以前的会话没有正确删除,后面有分配过来了
417
423
  if (this.sessionMap[data.conversationId]) {
424
+ // 如果会话比较老,就不更新属性
425
+ if (this.sessionMap[data.conversationId].lastMsgTime && data.lastMsgTime && this.sessionMap[data.conversationId].lastMsgTime <= data.lastMsgTime) {
426
+ // 先删后插
427
+ this._removeSessionBySessionGroup(this.sessionMap[data.conversationId].conversationId)
428
+ // 更新属性
429
+ Object.keys(data).forEach(k => {
430
+ Vue.set(this.sessionMap[data.conversationId], k, data[k])
431
+ })
432
+ }
418
433
  nextData = this.sessionMap[data.conversationId]
434
+ isRefreshAll = true
419
435
  } else {
420
- this.sessionMap[data.conversationId] = nextData
436
+ nextData = data
421
437
  }
422
- const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
423
- if (wechatAccountId && wechatAccountId !== ALL_WECHAT_ACCOUNT_ID && nextData.wechatAccountId !== wechatAccountId) {
424
- throw new Error('会话的wechatAccount和加载分组的wechatAccountId不一致')
438
+ if (!nextData) {
439
+ return
425
440
  }
426
- const groupIds = []
427
- // 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
428
441
  if (wechatAccountId) {
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
- })
442
+ // 传了wechatAccountId,是分页加载的,这里要保持分页加载数据的链路不受动态加载的影响
443
+ // 加载会话是新的在上面,老的在下面,所以一定要记录好上次分页加载的时间点
444
+ if (isRefreshAll) {
445
+ groupIds.push(nextData.wechatAccountId)
446
+ groupIds.push(ALL_WECHAT_ACCOUNT_ID)
447
+ } else {
448
+ groupIds.push(wechatAccountId)
449
+ }
450
+ // 先把老的删除掉
451
+ this._removeLastUpdateSessionMap(nextData.conversationId, wechatAccountId)
452
+ // 再插入新的
453
+ this._updateLastUpdateSessionMap([wechatAccountId], nextData)
459
454
  } else {
460
455
  groupIds.push(nextData.wechatAccountId)
461
456
  groupIds.push(ALL_WECHAT_ACCOUNT_ID)
462
457
  }
458
+ this.sessionMap[data.conversationId] = nextData
463
459
  // 分组的
464
460
  const sortFields = this.getSortField(nextData.lastMsgTime)
461
+ const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
465
462
  groupIds.forEach(groupId => {
466
463
  // 如果已经在分组里面了,就不新增了,
467
464
  if (this._getSessionBySessionGroup(nextData.conversationId, groupId)) {
@@ -492,6 +489,10 @@ export default class ClientChatSession {
492
489
  Vue.set(this.data.sessionMuteMap, nextData.wechatAccountId, {})
493
490
  }
494
491
  Vue.set(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId, nextData)
492
+ } else {
493
+ if (this.data.sessionMuteMap[nextData.wechatAccountId]) {
494
+ Vue.delete(this.data.sessionMuteMap[nextData.wechatAccountId], nextData.conversationId)
495
+ }
495
496
  }
496
497
  // 检测一下是不是存在一样的虚拟会话,存在的话就删除
497
498
  const virtualSessionIndex = this.data.virtualSessionData.findIndex(v => v.conversationId === nextData.conversationId)
@@ -499,14 +500,53 @@ export default class ClientChatSession {
499
500
  this.data.virtualSessionData.splice(virtualSessionIndex, 1)
500
501
  }
501
502
  callback && callback({
502
- session: data
503
+ session: nextData
503
504
  })
504
505
  this.onAddSession && this.onAddSession({
505
- session: data
506
+ session: nextData
506
507
  })
507
508
  }
508
-
509
- removeSession (conversationId) {
509
+
510
+ _updateLastUpdateSessionMap (groupIds, nextData) {
511
+ if (!groupIds || !groupIds.length || !nextData) {
512
+ return
513
+ }
514
+ // 传了wechatAccountId才记录lastMsgTime
515
+ const lastFields = ['lastMsgTime']
516
+ const topField = nextData.stickyOnTop ? 0 : 1 // 置顶
517
+ groupIds.forEach(groupId => {
518
+ lastFields.forEach(lastField => {
519
+ const lastUpdateSortFields = this.getSortField(nextData[lastField])
520
+ if (!lastUpdateSortFields) {
521
+ return
522
+ }
523
+ if (!this._lastUpdateSessionMap) {
524
+ this._lastUpdateSessionMap = {}
525
+ }
526
+ if (!this._lastUpdateSessionMap[groupId]) {
527
+ this._lastUpdateSessionMap[groupId] = {}
528
+ }
529
+ if (!this._lastUpdateSessionMap[groupId][lastField]) {
530
+ this._lastUpdateSessionMap[groupId][lastField] = {}
531
+ }
532
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
533
+ this._lastUpdateSessionMap[groupId][lastField][topField] = {}
534
+ }
535
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day]) {
536
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day] = {}
537
+ }
538
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds]) {
539
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds] = []
540
+ }
541
+ this._lastUpdateSessionMap[groupId][lastField][topField][lastUpdateSortFields.day][lastUpdateSortFields.milliseconds].push({
542
+ conversationId: nextData.conversationId,
543
+ lastMsgTime: nextData.lastMsgTime
544
+ })
545
+ })
546
+ })
547
+ }
548
+
549
+ _removeSessionBySessionGroup (conversationId, wechatAccountId) {
510
550
  if (!this.sessionMap[conversationId]) {
511
551
  return
512
552
  }
@@ -515,7 +555,7 @@ export default class ClientChatSession {
515
555
  return
516
556
  }
517
557
  const topField = session.stickyOnTop ? 0 : 1 // 置顶
518
- const groupIds = [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
558
+ const groupIds = wechatAccountId ? [wechatAccountId] : [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
519
559
  const sortFields = this.getSortField(session.lastMsgTime)
520
560
  groupIds.forEach(groupId => {
521
561
  if (!this.data.sessionGroupData[groupId] || !this.data.sessionGroupData[groupId][topField]) {
@@ -523,7 +563,7 @@ export default class ClientChatSession {
523
563
  }
524
564
  const groupSession = this.data.sessionGroupData[groupId][topField]
525
565
  if (groupSession[sortFields.day] && groupSession[sortFields.day][sortFields.milliseconds]) {
526
- const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(this.sessionMap[conversationId])
566
+ const groupIndex = groupSession[sortFields.day][sortFields.milliseconds].indexOf(session)
527
567
  if (groupIndex >= 0) {
528
568
  groupSession[sortFields.day][sortFields.milliseconds].splice(groupIndex, 1)
529
569
  }
@@ -541,10 +581,19 @@ export default class ClientChatSession {
541
581
  }
542
582
  }
543
583
  })
544
- if (this.data.sessionMuteMap[session.wechatAccountId]) {
545
- delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
584
+ }
585
+
586
+ _removeLastUpdateSessionMap (conversationId, wechatAccountId) {
587
+ if (!this.sessionMap[conversationId]) {
588
+ return
589
+ }
590
+ const session = this.sessionMap[conversationId]
591
+ if (!session) {
592
+ return
546
593
  }
547
- const lastFields = ['lastMsgTime', 'lastUpdateTime']
594
+ let isDeleted = false
595
+ const lastFields = ['lastMsgTime']
596
+ const groupIds = wechatAccountId ? [wechatAccountId] : [session.wechatAccountId, ALL_WECHAT_ACCOUNT_ID]
548
597
  groupIds.forEach(groupId => {
549
598
  if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
550
599
  return
@@ -553,26 +602,93 @@ export default class ClientChatSession {
553
602
  if (!this._lastUpdateSessionMap[groupId][lastField]) {
554
603
  return
555
604
  }
605
+ const loastUpdateSortFields = this.getSortField(session[lastField])
556
606
  Object.keys(this._lastUpdateSessionMap[groupId][lastField]).forEach(topField => {
557
607
  if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
558
608
  return
559
609
  }
560
- const loastUpdateSortFields = this.getSortField(session.lastUpdateTime)
561
610
  if (this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day] && this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds]) {
562
- const index = this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].indexOf(session)
611
+ let index = -1
612
+ this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].some((v, i) => {
613
+ if (v.conversationId === session.conversationId) {
614
+ index = i
615
+ return true
616
+ }
617
+ })
563
618
  if (index >= 0) {
564
619
  this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].splice(index, 1)
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)
620
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day][loastUpdateSortFields.milliseconds].length) {
621
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day], loastUpdateSortFields.milliseconds)
622
+ }
623
+ if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][loastUpdateSortFields.day])) {
624
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], loastUpdateSortFields.day)
625
+ }
626
+ isDeleted = true
571
627
  }
572
628
  }
573
629
  })
574
630
  })
575
631
  })
632
+ if (!isDeleted) {
633
+ groupIds.some(groupId => {
634
+ if (!this._lastUpdateSessionMap || !this._lastUpdateSessionMap[groupId]) {
635
+ return
636
+ }
637
+ return lastFields.some(lastField => {
638
+ if (!this._lastUpdateSessionMap[groupId][lastField]) {
639
+ return
640
+ }
641
+ return Object.keys(this._lastUpdateSessionMap[groupId][lastField]).some(topField => {
642
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField]) {
643
+ return
644
+ }
645
+ return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField]).some(day => {
646
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][day]) {
647
+ return
648
+ }
649
+ return Object.keys(this._lastUpdateSessionMap[groupId][lastField][topField][day]).some(milliseconds => {
650
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds]) {
651
+ return
652
+ }
653
+ let index = -1
654
+ this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].some((v, i) => {
655
+ if (v.conversationId === session.conversationId) {
656
+ index = i
657
+ return true
658
+ }
659
+ })
660
+ if (index >= 0) {
661
+ this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].splice(index, 1)
662
+ if (!this._lastUpdateSessionMap[groupId][lastField][topField][day][milliseconds].length) {
663
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField][day], milliseconds)
664
+ }
665
+ if (isEmptyObject(this._lastUpdateSessionMap[groupId][lastField][topField][day])) {
666
+ Vue.delete(this._lastUpdateSessionMap[groupId][lastField][topField], day)
667
+ }
668
+ isDeleted = true
669
+ return true
670
+ }
671
+ })
672
+ })
673
+ })
674
+ })
675
+ })
676
+ }
677
+ }
678
+
679
+ removeSession (conversationId) {
680
+ if (!this.sessionMap[conversationId]) {
681
+ return
682
+ }
683
+ const session = this.sessionMap[conversationId]
684
+ if (!session) {
685
+ return
686
+ }
687
+ this._removeSessionBySessionGroup(conversationId)
688
+ this._removeLastUpdateSessionMap(conversationId)
689
+ if (this.data.sessionMuteMap[session.wechatAccountId]) {
690
+ delete this.data.sessionMuteMap[session.wechatAccountId][conversationId]
691
+ }
576
692
  delete this.sessionMap[conversationId]
577
693
  this.onRemoveSession && this.onRemoveSession({
578
694
  session
@@ -126,7 +126,11 @@ export default class ClientChatContacts {
126
126
  */
127
127
  roomBindMemberMap: {},
128
128
 
129
- modifiedAccountMap: {}
129
+ /**
130
+ * 标记通讯录是否修改了
131
+ * 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
132
+ */
133
+ isModify: false
130
134
  })
131
135
 
132
136
  friendMap = {}
@@ -233,6 +237,10 @@ export default class ClientChatContacts {
233
237
  return this.data.roomGroupData
234
238
  }
235
239
 
240
+ get isModify () {
241
+ return this.data.isModify
242
+ }
243
+
236
244
  setRoomGroup (data) {
237
245
  this.data.roomGroupData = []
238
246
  if (data && data.length) {
@@ -483,10 +491,10 @@ export default class ClientChatContacts {
483
491
  }
484
492
  }
485
493
  const qwAccountId = this.roomMap[id].qwAccountId
486
- if (qwAccountId && this.data.accountBindRoomMap[qwAccountId] && this.data.accountBindRoomMap[qwAccountId][groupId]) {
487
- const bindIndex = this.data.accountBindRoomMap[qwAccountId][groupId].indexOf(this.roomMap[id])
494
+ if (qwAccountId && this.data.accountBindFriendMap[qwAccountId] && this.data.accountBindFriendMap[qwAccountId][groupId]) {
495
+ const bindIndex = this.data.accountBindFriendMap[qwAccountId][groupId].indexOf(this.roomMap[id])
488
496
  if (bindIndex >= 0) {
489
- this.data.accountBindRoomMap[qwAccountId][groupId].splice(bindIndex, 1)
497
+ this.data.accountBindFriendMap[qwAccountId][groupId].splice(bindIndex, 1)
490
498
  }
491
499
  }
492
500
  })
@@ -620,37 +628,6 @@ export default class ClientChatContacts {
620
628
  return rs
621
629
  })
622
630
  }
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
- }
654
631
 
655
632
  setRoomMemberData (roomId, data) {
656
633
  if (!roomId) {
@@ -761,52 +738,12 @@ export default class ClientChatContacts {
761
738
  })
762
739
  }
763
740
 
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
- })
741
+ markModify () {
742
+ this.data.isModify = true
804
743
  }
805
744
 
806
- unmarkModify (qwAccountId) {
807
- if (qwAccountId) {
808
- Vue.delete(this.data.modifiedAccountMap, qwAccountId)
809
- }
745
+ unmarkModify () {
746
+ this.data.isModify = false
810
747
  }
811
748
 
812
749
  reset () {
@@ -821,7 +758,6 @@ export default class ClientChatContacts {
821
758
  this.data.groupBindRoomMap = {}
822
759
  this.data.accountBindFriendMap = {}
823
760
  this.data.accountBindRoomMap = {}
824
- this.data.modifiedAccountMap = {}
825
761
  this._cacheFriendGroupCountMap = null
826
762
  this._cacheRoomGroupCountMap = null
827
763
  if (this.cancelConnectRequest) {
@@ -833,4 +769,4 @@ export default class ClientChatContacts {
833
769
  this.cancelRefreshRequest = null
834
770
  }
835
771
  }
836
- }
772
+ }
@@ -2,7 +2,6 @@ import Vue from 'vue'
2
2
  import Event from '../../../utils/event.js'
3
3
  import { unique } from '../../../utils/string.js'
4
4
  import { formatDate } from '../../../utils/date.js'
5
- import { createPromise } from '../../../utils/util'
6
5
 
7
6
  export default class ClientChatMessage {
8
7
 
@@ -23,8 +22,6 @@ export default class ClientChatMessage {
23
22
  })
24
23
 
25
24
  messageMap = {}
26
- tempMessageMap = {}
27
- checkMessageSendResultTaskList = []
28
25
 
29
26
  get messageData () {
30
27
  return this.data.messageData
@@ -36,18 +33,15 @@ export default class ClientChatMessage {
36
33
  queryMethod: null,
37
34
  sortField: null, // 排序的字段,必须是唯一的,例如时间
38
35
  groupField: null, // 分组的字段
39
- checkMessageSendResultMethod: null,
40
36
  onAddMessageSuccess: null // 新增消息成功回调事件
41
37
  }, options)
42
38
  if (!options.clientChat) {
43
39
  throw new Error('必须将clientChat传递过来')
44
40
  }
45
- if (!options.checkMessageSendResultMethod) throw new Error('缺少checkMessageSendResultMethod配置')
46
41
  this.queryMethod = options.queryMethod
47
42
  this.clientChat = options.clientChat
48
43
  this.groupField = options.groupField
49
44
  this.sortField = options.sortField
50
- this.checkMessageSendResultMethod = options.checkMessageSendResultMethod
51
45
  this.onAddMessageSuccess = options.onAddMessageSuccess
52
46
  this.event = new Event()
53
47
  }
@@ -74,13 +68,13 @@ export default class ClientChatMessage {
74
68
  * "createTime": 1723710023517,
75
69
  * "id": "6612b84538679a8c881e9f8482ccda9e9b35c00d",
76
70
  * "isDeleted": false,
77
- * "send": false,
71
+ * "isSend": false,
78
72
  * "msgId": "1245",
79
73
  * "msgSubType": 0,
80
74
  * "msgSvrId": "4319123759514541049",
81
75
  * "msgType": 1,
82
76
  * "origin": "0",
83
- * "status": 0,
77
+ * "sendStatus": 0,
84
78
  * "tenantId": "1761952223049924608",
85
79
  * "wechatAccountId": "ad9d9ae2a8be4f27311312cdd4af3549dc8427ef",
86
80
  * "wechatFriendId": "2089efcc7f8f40b00b7f05fa4c6dfd3bb642774d",
@@ -95,10 +89,6 @@ export default class ClientChatMessage {
95
89
  if (this.messageMap[data.id]) {
96
90
  return
97
91
  }
98
- if (this.tempMessageMap[data.id]) {
99
- Object.assign(data, this.tempMessageMap[data.id])
100
- delete this.tempMessageMap[data.id]
101
- }
102
92
  const groupField = data[this.groupField]
103
93
  if (!this.data.messageData[groupField]) {
104
94
  Vue.set(this.data.messageData, groupField, {})
@@ -115,7 +105,6 @@ export default class ClientChatMessage {
115
105
  }
116
106
  this.data.messageData[groupField][sortFields.day][sortFields.milliseconds].push(data)
117
107
  this.messageMap[data.id] = data
118
- if (data.send && data.status === 1 && !data._temp) this.addCheckMessageSendResultTask(data)
119
108
  if (fireEvent !== false) {
120
109
  this.event && this.event.emit('add-message', {
121
110
  data
@@ -130,7 +119,6 @@ export default class ClientChatMessage {
130
119
  if (!id) {
131
120
  return
132
121
  }
133
- this.removeCheckMessageSendResultTask(id)
134
122
  const message = this.messageMap[id]
135
123
  if (!message) {
136
124
  return
@@ -166,7 +154,6 @@ export default class ClientChatMessage {
166
154
  updateMessage (id, props) {
167
155
  const message = this.getMessage(id)
168
156
  if (!message) {
169
- this.tempMessageMap[id] = props
170
157
  return
171
158
  }
172
159
  if (!props) {
@@ -228,11 +215,11 @@ export default class ClientChatMessage {
228
215
  }, data, {
229
216
  cmdType: 'CmdQwSendMessage'
230
217
  })).then(({ data }) => {
231
- if (data.status === 0) {
218
+ if (data.sendStatus === 0) {
232
219
  // 发送成功
233
- } else if (data.status === 2) {
220
+ } else if (data.sendStatus === 2) {
234
221
  // 发送失败
235
- } else if (data.status === 1) {
222
+ } else if (data.sendStatus === 1) {
236
223
  // 发送中
237
224
  }
238
225
  // 如果返回的是对象,证明发送成功了
@@ -286,35 +273,8 @@ export default class ClientChatMessage {
286
273
  this.clearMessage()
287
274
  return this.loadMessageData(params)
288
275
  }
289
-
290
- addCheckMessageSendResultTask (message) {
291
- if (this.checkMessageSendResultTaskList.some(v => v.id === message.id)) return
292
- let timer
293
- const task = { id: message.id, promise: createPromise(), check: () => {
294
- if (message.status !== 1) return task.promise.resolve()
295
- if (Date.now() - (message.createTime || message.sendTime) > 5 * 60 * 1000) return task.promise.resolve({status: 3, resultMsg: '消息发送超时'})
296
- timer = setTimeout(() => {
297
- Promise.resolve(this.checkMessageSendResultMethod({message})).then(rs => {
298
- const data = rs && rs.data
299
- if (data && data.status === 1) task.check()
300
- else task.promise.resolve(data || {})
301
- }, () => task.check())
302
- }, 3000)
303
- }, cancel: () => { clearTimeout(timer); task.promise.reject('reject') } }
304
- this.checkMessageSendResultTaskList.push(task)
305
- task.check()
306
- task.promise.then(rs => this.updateMessage(message.id, rs || {})).finally(() => this.removeCheckMessageSendResultTask(message.id))
307
- }
308
-
309
- removeCheckMessageSendResultTask (id) {
310
- const index = this.checkMessageSendResultTaskList.findIndex(v => v.id === id)
311
- if (index >= 0) { this.checkMessageSendResultTaskList[index].cancel(); this.checkMessageSendResultTaskList.splice(index, 1) }
312
- }
313
276
 
314
277
  reset () {
315
- this.checkMessageSendResultTaskList.forEach(task => task.cancel())
316
- this.checkMessageSendResultTaskList = []
317
- this.tempMessageMap = {}
318
278
  this.data.messageData = {}
319
279
  }
320
- }
280
+ }
@@ -82,8 +82,7 @@ export default class ClientChatSession {
82
82
  /**
83
83
  * 删除会话
84
84
  */
85
- deleteSessionMethod: null,
86
- modifiedAccountMap: {}
85
+ deleteSessionMethod: null
87
86
  })
88
87
 
89
88
  accountIds = []
@@ -120,23 +119,6 @@ export default class ClientChatSession {
120
119
  return this.data.loading
121
120
  }
122
121
 
123
- isModify (qwAccountId) {
124
- return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
125
- }
126
-
127
- markModify (qwAccountIds) {
128
- const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
129
- ids.filter(Boolean).forEach(id => {
130
- Vue.set(this.data.modifiedAccountMap, id, true)
131
- })
132
- }
133
-
134
- unmarkModify (qwAccountId) {
135
- if (qwAccountId) {
136
- Vue.delete(this.data.modifiedAccountMap, qwAccountId)
137
- }
138
- }
139
-
140
122
  get loadAssignTaskSessioning () {
141
123
  return this.data.loadAssignTaskSessioning
142
124
  }
@@ -223,35 +205,6 @@ export default class ClientChatSession {
223
205
  getSessionByLocal (sessionId) {
224
206
  return this.sessionMap[sessionId]
225
207
  }
226
-
227
- /**
228
- * 强制从服务端刷新会话,绕过本地缓存。
229
- */
230
- refreshSession (sessionId) {
231
- if (!sessionId) {
232
- return Promise.reject('缺少会话id')
233
- }
234
- return this.getSessionMethod({
235
- id: sessionId
236
- }).then(rs => {
237
- if (!rs || !rs.data) {
238
- return Promise.reject('未找到会话' + sessionId)
239
- }
240
- // 事件计算出的 sessionId 是本地索引,始终保持与服务端返回对象一致。
241
- const serverSession = Object.assign({}, rs.data, {
242
- id: sessionId
243
- })
244
- const localSession = this.getSessionByLocal(sessionId)
245
- if (localSession) {
246
- this.updateSession(sessionId, serverSession)
247
- } else {
248
- this.addSession(serverSession)
249
- }
250
- return Object.assign({}, rs, {
251
- data: serverSession
252
- })
253
- })
254
- }
255
208
 
256
209
  findSession (findFn) {
257
210
  let result
@@ -962,7 +915,6 @@ export default class ClientChatSession {
962
915
  this.data.sessionData = {}
963
916
  this.data.sessionGroupData = {}
964
917
  this.data.sessionMuteMap = {}
965
- this.data.modifiedAccountMap = {}
966
918
  // this.data.sessionUnreadCountMap = {}
967
919
  this.sessionMap = {}
968
920
  if (this.cancelLoadDataRequest) {
@@ -974,4 +926,4 @@ export default class ClientChatSession {
974
926
  this.cancelRefreshRequest = null
975
927
  }
976
928
  }
977
- }
929
+ }