提交 9876e87e 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 统一用conversation.getCached获取本地会话

上级 fe02bc90
......@@ -286,7 +286,7 @@
let isGroupAdmin = false
if(group_id){
let conversation = uniIm.conversation.dataList.find(i=>i.id == conversation_id)
let conversation = uniIm.conversation.getCached(conversation_id)
isGroupAdmin = conversation.group_info.user_id == current_uid
}
// console.log('isGroupAdmin',isGroupAdmin);
......
......@@ -191,7 +191,7 @@
},
computed: {
currentConversation() {
return uniIm.conversation.dataList.find(conversation => conversation.id == this.msg.conversation_id)
return uniIm.conversation.getCached(this.msg.conversation_id)
},
friendlyTime() {
let time = this.msg.create_time || this.msg.client_create_time
......@@ -222,8 +222,11 @@
}
},
isFromAdmin() {
const conversation = uniIm.conversation.dataList.find(conversation => conversation.id == this.msg.conversation_id)
return conversation.group_id && conversation.group_member[this.msg.from_uid]?.role?.includes('admin')
const {
group_id,
from_uid
} = this.msg
return group_id && this.currentConversation.group_member[from_uid]?.role?.includes('admin')
},
mineId() {
return uniCloud.getCurrentUserInfo().uid
......
......@@ -301,7 +301,7 @@ export default class Message {
if (!Array.isArray(datas)) {
datas = [datas]
}
let _currentConversation = $state.conversation.dataList.find(item => item.id == this.conversation_id)
let _currentConversation = $state.conversation.getCached(this.conversation_id)
// 隐藏的会话,收到消息后需要再次显示出来
if(_currentConversation.hidden){
_currentConversation.hidden = false
......
......@@ -59,7 +59,7 @@ function getCloudMsg({
conversationDatas.forEach(newConversationInfo => {
// console.error('newConversationInfo',newConversationInfo)
// 判断是否已经存在
let conversation = $state.conversation.dataList.find(item => item.id === newConversationInfo.id)
let conversation = $state.conversation.getCached(newConversationInfo.id)
if (conversation) {
// 更新本地会话数据
Object.assign(conversation, newConversationInfo)
......@@ -108,7 +108,7 @@ async function seaveMsgs(msgs) {
if (msgs.length === 0) {
return
}
const conversation = $state.conversation.dataList.find(item => item.id === msgs[0].conversation_id)
const conversation = $state.conversation.getCached(msgs[0].conversation_id)
msgs.sort((a, b) => a.update_time - b.update_time)
msgs.forEach(async msg => {
// 判断是否出现重复
......
......@@ -199,7 +199,7 @@ export default {
return datas.reduce((resList, item, index) => {
// console.log('resList',resList);
// 判断是否存在,再新增。
let conversation_item = $state.conversation.dataList.find(conversation => conversation.id == item.id)
let conversation_item = $state.conversation.getCached(item.id)
if (conversation_item) {
// 此会话已经存在,返回给add方法调用者,不重复插到$state.conversation.dataList
resList.push(conversation_item)
......@@ -216,7 +216,7 @@ export default {
$state.conversation.dataList.push(conversation)
// 拿到响应式的conversation对象
const _conversation = $state.conversation.dataList.find(i => i.id === conversation.id)
const _conversation = $state.conversation.getCached(conversation.id)
// 设置字段为响应式
let activeProperty = _conversation.activeProperty()
Object.keys(activeProperty).forEach(key => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册