@aochuang/client-sdk 1.0.312 → 1.0.314
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
|
@@ -83,7 +83,6 @@ export default class ClientChatContacts {
|
|
|
83
83
|
*/
|
|
84
84
|
roomData: [],
|
|
85
85
|
|
|
86
|
-
|
|
87
86
|
/**
|
|
88
87
|
* {
|
|
89
88
|
* groupId: [{
|
|
@@ -135,12 +134,26 @@ export default class ClientChatContacts {
|
|
|
135
134
|
* 标记通讯录是否修改了
|
|
136
135
|
* 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
|
|
137
136
|
*/
|
|
138
|
-
isModify: false
|
|
137
|
+
isModify: false,
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 缓存的好友分组统计数量
|
|
141
|
+
*/
|
|
142
|
+
cacheFriendGroupCountMap: {},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 缓存的群聊分组统计数量
|
|
146
|
+
*/
|
|
147
|
+
cacheRoomGroupCountMap: {}
|
|
139
148
|
})
|
|
140
149
|
|
|
141
150
|
friendMap = {}
|
|
142
151
|
|
|
143
152
|
roomMap = {}
|
|
153
|
+
|
|
154
|
+
_cacheFriendGroupCountMap = {}
|
|
155
|
+
|
|
156
|
+
_cacheRoomGroupCountMap = {}
|
|
144
157
|
|
|
145
158
|
loadContactsRoomGroupDataMethod = null
|
|
146
159
|
|
|
@@ -246,10 +259,18 @@ export default class ClientChatContacts {
|
|
|
246
259
|
return this.data.friendGroupData
|
|
247
260
|
}
|
|
248
261
|
|
|
262
|
+
get cacheFriendGroupCountMap () {
|
|
263
|
+
return this.data.cacheFriendGroupCountMap
|
|
264
|
+
}
|
|
265
|
+
|
|
249
266
|
get roomGroupData () {
|
|
250
267
|
return this.data.roomGroupData
|
|
251
268
|
}
|
|
252
269
|
|
|
270
|
+
get cacheRoomGroupCountMap () {
|
|
271
|
+
return this.data.cacheRoomGroupCountMap
|
|
272
|
+
}
|
|
273
|
+
|
|
253
274
|
get isModify () {
|
|
254
275
|
return this.data.isModify
|
|
255
276
|
}
|
|
@@ -589,10 +610,10 @@ export default class ClientChatContacts {
|
|
|
589
610
|
}
|
|
590
611
|
}
|
|
591
612
|
const wechatAccountId = this.roomMap[id].wechatAccountId
|
|
592
|
-
if (wechatAccountId && this.data.
|
|
593
|
-
const bindIndex = this.data.
|
|
613
|
+
if (wechatAccountId && this.data.accountBindRoomMap[wechatAccountId] && this.data.accountBindRoomMap[wechatAccountId][groupId]) {
|
|
614
|
+
const bindIndex = this.data.accountBindRoomMap[wechatAccountId][groupId].indexOf(this.roomMap[id])
|
|
594
615
|
if (bindIndex >= 0) {
|
|
595
|
-
this.data.
|
|
616
|
+
this.data.accountBindRoomMap[wechatAccountId][groupId].splice(bindIndex, 1)
|
|
596
617
|
}
|
|
597
618
|
}
|
|
598
619
|
})
|
|
@@ -720,15 +741,20 @@ export default class ClientChatContacts {
|
|
|
720
741
|
const { wechatAccountId, ...nextParams } = Object.assign({
|
|
721
742
|
wechatAccountId: null
|
|
722
743
|
}, params)
|
|
744
|
+
const cacheKey = wechatAccountId || 'all'
|
|
745
|
+
if (!this.data.cacheFriendGroupCountMap) {
|
|
746
|
+
this.data.cacheFriendGroupCountMap = {}
|
|
747
|
+
}
|
|
723
748
|
if (!this._cacheFriendGroupCountMap) {
|
|
724
749
|
this._cacheFriendGroupCountMap = {}
|
|
725
750
|
}
|
|
726
|
-
if (!this._cacheFriendGroupCountMap[
|
|
751
|
+
if (!this._cacheFriendGroupCountMap[cacheKey]) {
|
|
727
752
|
const groupIds = (this.data.friendGroupData || []).map(v => v.id)
|
|
728
753
|
groupIds.forEach(id => {
|
|
729
754
|
Vue.set(this.data.refreshFriendGroupCountLoadingMap, id, true)
|
|
730
755
|
})
|
|
731
|
-
|
|
756
|
+
Vue.set(this.data.cacheFriendGroupCountMap, cacheKey, true)
|
|
757
|
+
this._cacheFriendGroupCountMap[cacheKey] = this.getContactsFriendGroupCountMethod(Object.assign({}, nextParams, {
|
|
732
758
|
wechatAccountIds: wechatAccountId ? [wechatAccountId] : null,
|
|
733
759
|
groupIds
|
|
734
760
|
})).finally(() => {
|
|
@@ -737,7 +763,7 @@ export default class ClientChatContacts {
|
|
|
737
763
|
})
|
|
738
764
|
})
|
|
739
765
|
}
|
|
740
|
-
this._cacheFriendGroupCountMap[
|
|
766
|
+
this._cacheFriendGroupCountMap[cacheKey].then(rs => {
|
|
741
767
|
if (!rs || !rs.data || !rs.data.length) {
|
|
742
768
|
return
|
|
743
769
|
}
|
|
@@ -747,7 +773,21 @@ export default class ClientChatContacts {
|
|
|
747
773
|
})
|
|
748
774
|
})
|
|
749
775
|
})
|
|
750
|
-
return this._cacheFriendGroupCountMap[
|
|
776
|
+
return this._cacheFriendGroupCountMap[cacheKey]
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// 标记所有好友分组修改
|
|
780
|
+
// 需要清理缓存
|
|
781
|
+
clearAllFriendGroupCountCache (wechatAccountId) {
|
|
782
|
+
if (!this.data.cacheFriendGroupCountMap) {
|
|
783
|
+
return
|
|
784
|
+
}
|
|
785
|
+
if (this._cacheFriendGroupCountMap) {
|
|
786
|
+
delete this._cacheFriendGroupCountMap[wechatAccountId]
|
|
787
|
+
delete this._cacheFriendGroupCountMap.all
|
|
788
|
+
}
|
|
789
|
+
Vue.delete(this.data.cacheFriendGroupCountMap, wechatAccountId)
|
|
790
|
+
Vue.delete(this.data.cacheFriendGroupCountMap, 'all')
|
|
751
791
|
}
|
|
752
792
|
|
|
753
793
|
loadRoomGroupData () {
|
|
@@ -773,15 +813,20 @@ export default class ClientChatContacts {
|
|
|
773
813
|
const { wechatAccountId, ...nextParams } = Object.assign({
|
|
774
814
|
wechatAccountId: null
|
|
775
815
|
}, params)
|
|
816
|
+
if (!this.data.cacheRoomGroupCountMap) {
|
|
817
|
+
this.data.cacheRoomGroupCountMap = {}
|
|
818
|
+
}
|
|
776
819
|
if (!this._cacheRoomGroupCountMap) {
|
|
777
820
|
this._cacheRoomGroupCountMap = {}
|
|
778
821
|
}
|
|
779
|
-
|
|
822
|
+
const cacheKey = wechatAccountId || 'all'
|
|
823
|
+
if (!this._cacheRoomGroupCountMap[cacheKey] || refresh === true) {
|
|
780
824
|
const groupIds = (this.data.roomGroupData || []).map(v => v.id)
|
|
781
825
|
groupIds.forEach(id => {
|
|
782
826
|
Vue.set(this.data.refreshRoomGroupCountLoadingMap, id, true)
|
|
783
827
|
})
|
|
784
|
-
|
|
828
|
+
Vue.set(this.data.cacheRoomGroupCountMap, cacheKey, true)
|
|
829
|
+
this._cacheRoomGroupCountMap[cacheKey] = this.getContactsRoomGroupCountMethod(Object.assign({}, nextParams, {
|
|
785
830
|
wechatAccountIds: wechatAccountId ? [wechatAccountId] : null,
|
|
786
831
|
groupIds
|
|
787
832
|
})).finally(() => {
|
|
@@ -790,7 +835,7 @@ export default class ClientChatContacts {
|
|
|
790
835
|
})
|
|
791
836
|
})
|
|
792
837
|
}
|
|
793
|
-
this._cacheRoomGroupCountMap[
|
|
838
|
+
this._cacheRoomGroupCountMap[cacheKey].then(rs => {
|
|
794
839
|
if (!rs || !rs.data || !rs.data.length) {
|
|
795
840
|
return
|
|
796
841
|
}
|
|
@@ -800,7 +845,19 @@ export default class ClientChatContacts {
|
|
|
800
845
|
})
|
|
801
846
|
})
|
|
802
847
|
})
|
|
803
|
-
return this._cacheRoomGroupCountMap[
|
|
848
|
+
return this._cacheRoomGroupCountMap[cacheKey]
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
clearAllRoomGroupCountCache (wechatAccountId) {
|
|
852
|
+
if (!this.data.cacheRoomGroupCountMap) {
|
|
853
|
+
return
|
|
854
|
+
}
|
|
855
|
+
if (this._cacheRoomGroupCountMap) {
|
|
856
|
+
delete this._cacheRoomGroupCountMap[wechatAccountId]
|
|
857
|
+
delete this._cacheRoomGroupCountMap.all
|
|
858
|
+
}
|
|
859
|
+
Vue.delete(this.data.cacheRoomGroupCountMap, wechatAccountId)
|
|
860
|
+
Vue.delete(this.data.cacheRoomGroupCountMap, 'all')
|
|
804
861
|
}
|
|
805
862
|
|
|
806
863
|
getFriend (friendId, refresh) {
|
|
@@ -1001,11 +1058,13 @@ export default class ClientChatContacts {
|
|
|
1001
1058
|
}
|
|
1002
1059
|
|
|
1003
1060
|
markModify () {
|
|
1004
|
-
this.data.isModify = true
|
|
1061
|
+
// this.data.isModify = true
|
|
1062
|
+
console.warn('[ClientChat]markModify已过期')
|
|
1005
1063
|
}
|
|
1006
1064
|
|
|
1007
1065
|
unmarkModify () {
|
|
1008
|
-
this.data.isModify = false
|
|
1066
|
+
// this.data.isModify = false
|
|
1067
|
+
console.warn('[ClientChat]markModify已过期')
|
|
1009
1068
|
}
|
|
1010
1069
|
|
|
1011
1070
|
reset () {
|
|
@@ -1022,6 +1081,8 @@ export default class ClientChatContacts {
|
|
|
1022
1081
|
this.data.accountBindRoomMap = {}
|
|
1023
1082
|
this.data.refreshRoomGroupCountLoadingMap = {}
|
|
1024
1083
|
this.data.refreshFriendGroupCountLoadingMap = {}
|
|
1084
|
+
this.data.cacheFriendGroupCountMap = null
|
|
1085
|
+
this.data.cacheRoomGroupCountMap = null
|
|
1025
1086
|
this._cacheFriendGroupCountMap = null
|
|
1026
1087
|
this._cacheRoomGroupCountMap = null
|
|
1027
1088
|
if (this.cancelConnectRequest) {
|
|
@@ -747,17 +747,17 @@ class ClientChat {
|
|
|
747
747
|
this.socket.doHeartbeat()
|
|
748
748
|
},
|
|
749
749
|
onCurrentAccountChange: ({ currentAccount }) => {
|
|
750
|
-
// 如果群分组数据加载了再去刷成员数量,这样可以做到按需
|
|
751
|
-
if (this.contacts.friendGroupData && this.contacts.friendGroupData.length) {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
if (this.contacts.roomGroupData && this.contacts.roomGroupData.length) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
750
|
+
// // 如果群分组数据加载了再去刷成员数量,这样可以做到按需
|
|
751
|
+
// if (this.contacts.friendGroupData && this.contacts.friendGroupData.length) {
|
|
752
|
+
// this.contacts.refreshAllFriendGroupCount({
|
|
753
|
+
// wechatAccountId: currentAccount ? currentAccount.id : null
|
|
754
|
+
// })
|
|
755
|
+
// }
|
|
756
|
+
// if (this.contacts.roomGroupData && this.contacts.roomGroupData.length) {
|
|
757
|
+
// this.contacts.refreshAllRoomGroupCount({
|
|
758
|
+
// wechatAccountId: currentAccount ? currentAccount.id : null
|
|
759
|
+
// })
|
|
760
|
+
// }
|
|
761
761
|
},
|
|
762
762
|
onUnreadMessageNumChange: ({ accountId, unreadMessageNum }) => {
|
|
763
763
|
if (unreadMessageNum === 0) {
|
|
@@ -876,28 +876,31 @@ class ClientChat {
|
|
|
876
876
|
rs[v.wechatAccountId] = true
|
|
877
877
|
return rs
|
|
878
878
|
}, {}))
|
|
879
|
-
|
|
880
|
-
|
|
879
|
+
// 删除changeType为3移除的好友,例如转移的场景
|
|
880
|
+
if (data.friends && data.friends.length) {
|
|
881
|
+
data.friends.forEach(friend => {
|
|
882
|
+
if (friend.changeType === 3) {
|
|
883
|
+
this.contacts.removeFriend(friend.wechatFriendId)
|
|
884
|
+
}
|
|
885
|
+
})
|
|
881
886
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
this.
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
wechatAccountId: v
|
|
893
|
-
}, true)
|
|
894
|
-
)
|
|
895
|
-
return rs
|
|
896
|
-
}, [
|
|
897
|
-
// 刷新一下微信号
|
|
898
|
-
this.account.reloadData()
|
|
899
|
-
]))).then(() => {
|
|
887
|
+
let ps = Promise.resolve()
|
|
888
|
+
if (wechatAccountIds && wechatAccountIds.length) {
|
|
889
|
+
// 只要有一个不在现在的accountData里面,就需要重新加载微信号数据
|
|
890
|
+
if (wechatAccountIds.some(v => !this.account.accountMap[v])) {
|
|
891
|
+
ps = this.account.reloadData()
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return ps.finally(() => {
|
|
895
|
+
// 这里应该标记那些工作微信号的通讯录修改了,后面要在界面打个提示,告诉用户通讯录变化了,让手动刷新一下
|
|
896
|
+
// 同时也将缓存都清理一下,例如工作微信号分组统计数量等
|
|
900
897
|
this.contacts.markModify() // 标记通讯录修改
|
|
898
|
+
// 标记工作微信号所有好友分组修改
|
|
899
|
+
if (data.wechatAccountIds && data.wechatAccountIds) {
|
|
900
|
+
data.wechatAccountIds.forEach(wechatAccountId => {
|
|
901
|
+
this.contacts.clearAllFriendGroupCountCache(wechatAccountId)
|
|
902
|
+
})
|
|
903
|
+
}
|
|
901
904
|
})
|
|
902
905
|
})
|
|
903
906
|
}
|
|
@@ -928,11 +931,41 @@ class ClientChat {
|
|
|
928
931
|
onCmdChatroomInfoChanged: ({ data }) => {
|
|
929
932
|
// 配分群聊
|
|
930
933
|
if (data.changeType === 4) {
|
|
931
|
-
//
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
934
|
+
// 增量拉取分配产生的会话
|
|
935
|
+
return this.session.loadAssignTaskSessionData({
|
|
936
|
+
taskId: data.taskId
|
|
937
|
+
}).then((rs) => {
|
|
938
|
+
const wechatAccountIds = Object.keys((rs || []).reduce((rs, v) => {
|
|
939
|
+
rs[v.wechatAccountId] = true
|
|
940
|
+
return rs
|
|
941
|
+
}, {}))
|
|
942
|
+
// 删除changeType为3移除的群聊,例如转移的场景
|
|
943
|
+
if (data.chatrooms && data.chatrooms.length) {
|
|
944
|
+
data.chatrooms.forEach(room => {
|
|
945
|
+
if (room.changeType === 3) {
|
|
946
|
+
this.contacts.removeRoom(room.wechatChatroomId)
|
|
947
|
+
}
|
|
948
|
+
})
|
|
949
|
+
}
|
|
950
|
+
let ps = Promise.resolve()
|
|
951
|
+
if (wechatAccountIds && wechatAccountIds.length) {
|
|
952
|
+
// 只要有一个不在现在的accountData里面,就需要重新加载微信号数据
|
|
953
|
+
if (wechatAccountIds.some(v => !this.account.accountMap[v])) {
|
|
954
|
+
ps = this.account.reloadData()
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return ps.finally(() => {
|
|
958
|
+
// 这里应该标记那些工作微信号的通讯录修改了,后面要在界面打个提示,告诉用户通讯录变化了,让手动刷新一下
|
|
959
|
+
// 同时也将缓存都清理一下,例如工作微信号分组统计数量等
|
|
960
|
+
this.contacts.markModify() // 标记通讯录修改
|
|
961
|
+
// 标记工作微信号所有好友分组修改,标记修改后后面不会走缓存
|
|
962
|
+
if (data.wechatAccountIds && data.wechatAccountIds) {
|
|
963
|
+
data.wechatAccountIds.forEach(wechatAccountId => {
|
|
964
|
+
this.contacts.clearAllRoomGroupCountCache(wechatAccountId)
|
|
965
|
+
})
|
|
966
|
+
}
|
|
967
|
+
})
|
|
968
|
+
})
|
|
936
969
|
}
|
|
937
970
|
// 删除群聊
|
|
938
971
|
else if (data.changeType === 3) {
|