@aochuang/client-sdk 1.0.313 → 1.0.315
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/package.json
CHANGED
|
@@ -23,6 +23,7 @@ export default class ClientChatAccount {
|
|
|
23
23
|
updateAccountMessageReadMethod: null,
|
|
24
24
|
deleteAccountSessionMethod: null,
|
|
25
25
|
getAccountGreetingUnreadMsgCountMethod: null,
|
|
26
|
+
batchGetAccountGreetingUnreadMsgCountMethod: null,
|
|
26
27
|
clearAccountGreetingUnreadMsgCountMethod: null,
|
|
27
28
|
onCurrentAccountChange: null,
|
|
28
29
|
onAccountAdded: null,
|
|
@@ -43,6 +44,7 @@ export default class ClientChatAccount {
|
|
|
43
44
|
this.updateAccountMessageReadMethod = options.updateAccountMessageReadMethod
|
|
44
45
|
this.deleteAccountSessionMethod = options.deleteAccountSessionMethod
|
|
45
46
|
this.getAccountGreetingUnreadMsgCountMethod = options.getAccountGreetingUnreadMsgCountMethod
|
|
47
|
+
this.batchGetAccountGreetingUnreadMsgCountMethod = options.batchGetAccountGreetingUnreadMsgCountMethod
|
|
46
48
|
this.clearAccountGreetingUnreadMsgCountMethod = options.clearAccountGreetingUnreadMsgCountMethod
|
|
47
49
|
this.onAccountAdded = options.onAccountAdded
|
|
48
50
|
this.onAccountRemoved = options.onAccountRemoved,
|
|
@@ -394,6 +396,41 @@ export default class ClientChatAccount {
|
|
|
394
396
|
})
|
|
395
397
|
}
|
|
396
398
|
|
|
399
|
+
/**
|
|
400
|
+
* 批量获取所有账号的打招呼未读消息总数
|
|
401
|
+
*/
|
|
402
|
+
refreshAllAccountGreetingUnreadMsgCount () {
|
|
403
|
+
if (!this.batchGetAccountGreetingUnreadMsgCountMethod) {
|
|
404
|
+
return new Error('batchGetAccountGreetingUnreadMsgCountMethod未定义')
|
|
405
|
+
}
|
|
406
|
+
const wechatAccountIds = this.data.accountData.map(v => v.id).filter((id, index, data) => id && data.indexOf(id) === index)
|
|
407
|
+
const countData = {}
|
|
408
|
+
let requestPromise = Promise.resolve()
|
|
409
|
+
for (let index = 0; index < wechatAccountIds.length; index += 100) {
|
|
410
|
+
const currentWechatAccountIds = wechatAccountIds.slice(index, index + 100)
|
|
411
|
+
requestPromise = requestPromise.then(() => {
|
|
412
|
+
return this.batchGetAccountGreetingUnreadMsgCountMethod({
|
|
413
|
+
wechatAccountIds: currentWechatAccountIds
|
|
414
|
+
})
|
|
415
|
+
}).then(rs => {
|
|
416
|
+
;(rs && rs.data || []).forEach(item => {
|
|
417
|
+
if (item && item.wechatAccountId) {
|
|
418
|
+
countData[item.wechatAccountId] = item.count || 0
|
|
419
|
+
}
|
|
420
|
+
})
|
|
421
|
+
})
|
|
422
|
+
}
|
|
423
|
+
return requestPromise.then(() => {
|
|
424
|
+
let allCount = 0
|
|
425
|
+
wechatAccountIds.forEach(wechatAccountId => {
|
|
426
|
+
const count = countData[wechatAccountId] || 0
|
|
427
|
+
Vue.set(this.accountGreetingUnreadMsgCountData, wechatAccountId, count)
|
|
428
|
+
allCount += count
|
|
429
|
+
})
|
|
430
|
+
Vue.set(this.accountGreetingUnreadMsgCountData, 'all', allCount)
|
|
431
|
+
})
|
|
432
|
+
}
|
|
433
|
+
|
|
397
434
|
/**
|
|
398
435
|
* 清空打招呼未读消息总数
|
|
399
436
|
*/
|
|
@@ -414,10 +451,11 @@ export default class ClientChatAccount {
|
|
|
414
451
|
reset () {
|
|
415
452
|
this.data.accountData = []
|
|
416
453
|
this.data.accountUnreadMessageNumData = []
|
|
454
|
+
this.data.accountGreetingUnreadMsgCountData = {}
|
|
417
455
|
if (this.cancelConnectRequest) {
|
|
418
456
|
this.cancelConnectRequest()
|
|
419
457
|
}
|
|
420
458
|
this._cacheLoadPromise = null
|
|
421
459
|
this.cancelConnectRequest = null
|
|
422
460
|
}
|
|
423
|
-
}
|
|
461
|
+
}
|
|
@@ -93,6 +93,7 @@ class ClientChat {
|
|
|
93
93
|
updateAccountMessageReadMethod: null,
|
|
94
94
|
deleteAccountSessionMethod: null,
|
|
95
95
|
getAccountGreetingUnreadMsgCountMethod: null,
|
|
96
|
+
batchGetAccountGreetingUnreadMsgCountMethod: null,
|
|
96
97
|
clearAccountGreetingUnreadMsgCountMethod: null,
|
|
97
98
|
loadContactsRoomGroupDataMethod: null,
|
|
98
99
|
loadContactsFriendGroupDataMethod: null,
|
|
@@ -737,6 +738,7 @@ class ClientChat {
|
|
|
737
738
|
updateAccountMessageReadMethod: options.updateAccountMessageReadMethod,
|
|
738
739
|
deleteAccountSessionMethod: options.deleteAccountSessionMethod,
|
|
739
740
|
getAccountGreetingUnreadMsgCountMethod: options.getAccountGreetingUnreadMsgCountMethod,
|
|
741
|
+
batchGetAccountGreetingUnreadMsgCountMethod: options.batchGetAccountGreetingUnreadMsgCountMethod,
|
|
740
742
|
clearAccountGreetingUnreadMsgCountMethod: options.clearAccountGreetingUnreadMsgCountMethod,
|
|
741
743
|
onAccountAdded: ({ account }) => {
|
|
742
744
|
return this.account.refreshAccountUnreadMessageNum({
|
|
@@ -745,6 +747,7 @@ class ClientChat {
|
|
|
745
747
|
},
|
|
746
748
|
onAccountLoaded: () => {
|
|
747
749
|
this.socket.doHeartbeat()
|
|
750
|
+
this.account.refreshAllAccountGreetingUnreadMsgCount().catch(() => {})
|
|
748
751
|
},
|
|
749
752
|
onCurrentAccountChange: ({ currentAccount }) => {
|
|
750
753
|
// // 如果群分组数据加载了再去刷成员数量,这样可以做到按需
|
|
@@ -877,8 +880,8 @@ class ClientChat {
|
|
|
877
880
|
return rs
|
|
878
881
|
}, {}))
|
|
879
882
|
// 删除changeType为3移除的好友,例如转移的场景
|
|
880
|
-
if (data.
|
|
881
|
-
data.
|
|
883
|
+
if (data.friends && data.friends.length) {
|
|
884
|
+
data.friends.forEach(friend => {
|
|
882
885
|
if (friend.changeType === 3) {
|
|
883
886
|
this.contacts.removeFriend(friend.wechatFriendId)
|
|
884
887
|
}
|
|
@@ -939,9 +942,9 @@ class ClientChat {
|
|
|
939
942
|
rs[v.wechatAccountId] = true
|
|
940
943
|
return rs
|
|
941
944
|
}, {}))
|
|
942
|
-
// 删除changeType为3
|
|
943
|
-
if (data.
|
|
944
|
-
data.
|
|
945
|
+
// 删除changeType为3移除的群聊,例如转移的场景
|
|
946
|
+
if (data.chatrooms && data.chatrooms.length) {
|
|
947
|
+
data.chatrooms.forEach(room => {
|
|
945
948
|
if (room.changeType === 3) {
|
|
946
949
|
this.contacts.removeRoom(room.wechatChatroomId)
|
|
947
950
|
}
|