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

新增 支持用户设置自己的会话为已读/未读

上级 6142e428
......@@ -170,7 +170,7 @@ export default {
"left": clientX
}
let menuList = [{
"title": "置顶",
"title": conversation.pinned ? "取消置顶" : "置顶",
"action": () => {
conversation.pinned = !conversation.pinned
db.collection('uni-im-conversation')
......@@ -190,6 +190,12 @@ export default {
})
}
},
{
"title": "标为" + (conversation.unread_count ? "已读" : "未读"),
"action": () => {
conversation.setUnreadCount(conversation.unread_count ? 0 : 1)
}
},
{
"title": conversation.mute ? "允许消息通知" : "消息免打扰",
"action": () => {
......@@ -211,9 +217,6 @@ export default {
"action": () => conversation.hide()
}
]
if (conversation.pinned) {
menuList[0].title = "取消置顶"
}
myContextmenu.show(position, menuList)
myContextmenu.onClose(() => {
conversation.focus = false
......
......@@ -389,6 +389,25 @@ class Conversation {
console.log('updated hidden', res)
return res
}
// 设置未读消息数
async setUnreadCount(count) {
// console.log('setUnreadCount', count);
const oldCount = this.unread_count
this.unread_count = count
let res = await db.collection('uni-im-conversation')
.doc(this._id)
.update({
"unread_count": count
})
.catch(err => {
console.error('setUnreadCount err', err);
this.unread_count = oldCount
})
.then(e => {
// console.log('setUnreadCount updated', e.result.updated);
})
return res
}
}
export default Conversation
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册