diff --git a/components/uni-im-conversation-list/uni-im-conversation-list.vue b/components/uni-im-conversation-list/uni-im-conversation-list.vue index 8249bb362c0ae5d6c824e466b37e523da7307bb1..6088b9459b12d9e1d6eed5c206dd21a75e33b5e1 100644 --- a/components/uni-im-conversation-list/uni-im-conversation-list.vue +++ b/components/uni-im-conversation-list/uni-im-conversation-list.vue @@ -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 diff --git a/sdk/methods/conversation/Conversation.class.js b/sdk/methods/conversation/Conversation.class.js index 74960273f7de1f47551a22b9829d698e2d5ed8d7..189266d4789660a43dee74f996f95918a0f47b32 100644 --- a/sdk/methods/conversation/Conversation.class.js +++ b/sdk/methods/conversation/Conversation.class.js @@ -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