Browse Source

!153 fix: 开启免打扰时已读状态异常的bug

Merge pull request !153 from blue/v_3.0.0
master
blue 9 months ago
committed by Gitee
parent
commit
9ecb37d518
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
  1. 6
      im-uniapp/components/chat-item/chat-item.vue
  2. 8
      im-uniapp/pages/chat/chat-box.vue
  3. 2
      im-uniapp/pages/chat/chat.vue
  4. 6
      im-uniapp/store/chatStore.js
  5. 17
      im-web/src/components/chat/ChatBox.vue
  6. 2
      im-web/src/components/chat/ChatItem.vue
  7. 6
      im-web/src/store/chatStore.js
  8. 8
      im-web/src/view/Home.vue

6
im-uniapp/components/chat-item/chat-item.vue

@ -17,8 +17,8 @@
<view class="chat-send-name" v-if="isShowSendName">{{ chat.sendNickName + ':&nbsp;' }}</view>
<rich-text class="chat-content-text"
:nodes="$emo.transform(chat.lastContent,'emoji-small')"></rich-text>
<uni-badge v-if="chat.unreadCount > 0" :max-num="99" :text="chat.unreadCount" />
<view v-if="chat.isDnd" class="icon iconfont icon-dnd"></view>
<uni-badge v-else-if="chat.unreadCount > 0" :max-num="99" :text="chat.unreadCount" />
</view>
</view>
</view>
@ -170,9 +170,11 @@ export default {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.icon {
font-size: $im-font-size;
}
}
}
}

8
im-uniapp/pages/chat/chat-box.vue

@ -669,9 +669,7 @@ export default {
});
},
readedMessage() {
if (this.unreadCount == 0) {
return;
}
if (this.unreadCount > 0) {
let url = ""
if (this.chat.type == "GROUP") {
url = `/message/group/readed?groupId=${this.chat.targetId}`
@ -681,9 +679,9 @@ export default {
this.$http({
url: url,
method: 'PUT'
}).then(() => {
}).then(() => {})
}
this.chatStore.resetUnreadCount(this.chat)
})
},
loadGroup(groupId) {
this.$http({

2
im-uniapp/pages/chat/chat.vue

@ -104,7 +104,7 @@ export default {
unreadCount() {
let count = 0;
this.chatStore.chats.forEach(chat => {
if (!chat.delete) {
if (!chat.isDnd && !chat.delete) {
count += chat.unreadCount;
}
})

6
im-uniapp/store/chatStore.js

@ -195,7 +195,7 @@ export default defineStore('chatStore', {
chat.lastSendTime = msgInfo.sendTime;
chat.sendNickName = msgInfo.sendNickName;
// 未读加1
if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) {
chat.unreadCount++;
}
@ -354,7 +354,6 @@ export default defineStore('chatStore', {
let chat = this.findChat(chatInfo);
if (chat) {
chat.isDnd = isDnd;
chat.unreadCount = 0;
}
},
refreshChats() {
@ -374,9 +373,6 @@ export default defineStore('chatStore', {
chat.isDnd = group.isDnd
}
}
if (chat.isDnd) {
chat.unreadCount = 0;
}
})
// 排序
cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime);

17
im-web/src/components/chat/ChatBox.vue

@ -11,10 +11,9 @@
<el-main class="im-chat-main" id="chatScrollBox" @scroll="onScroll">
<div class="im-chat-box">
<div v-for="(msgInfo, idx) in showMessages" :key="showMinIdx + idx">
<chat-message-item @call="onCall(msgInfo.type)"
:mine="msgInfo.sendId == mine.id" :headImage="headImage(msgInfo)"
:showName="showName(msgInfo)" :msgInfo="msgInfo" :groupMembers="groupMembers"
@delete="deleteMessage" @recall="recallMessage">
<chat-message-item @call="onCall(msgInfo.type)" :mine="msgInfo.sendId == mine.id"
:headImage="headImage(msgInfo)" :showName="showName(msgInfo)" :msgInfo="msgInfo"
:groupMembers="groupMembers" @delete="deleteMessage" @recall="recallMessage">
</chat-message-item>
</div>
</div>
@ -505,11 +504,8 @@ export default {
});
},
readedMessage() {
if (this.chat.unreadCount == 0) {
return;
}
this.chatStore.resetUnreadCount(this.chat)
if (this.chat.type == "GROUP") {
if (this.chat.unreadCount > 0) {
if (this.isGroup) {
var url = `/message/group/readed?groupId=${this.chat.targetId}`
} else {
url = `/message/private/readed?friendId=${this.chat.targetId}`
@ -518,6 +514,8 @@ export default {
url: url,
method: 'put'
}).then(() => { })
this.chatStore.resetUnreadCount(this.chat)
}
},
loadReaded(fId) {
this.$http({
@ -682,7 +680,6 @@ export default {
return this.chat.unreadCount;
},
showMessages() {
console.log("this.chat.messages.slice(this.showMinIdx):",this.chat.messages.slice(this.showMinIdx))
return this.chat.messages.slice(this.showMinIdx)
},
messageSize() {

2
im-web/src/components/chat/ChatItem.vue

@ -3,7 +3,7 @@
<div class="chat-left">
<head-image :url="chat.headImage" :name="chat.showName" :size="42"
:id="chat.type == 'PRIVATE' ? chat.targetId : 0" :isShowUserInfo="false"></head-image>
<div v-show="chat.unreadCount > 0" class="unread-text">{{ chat.unreadCount }}</div>
<div v-show="!chat.isDnd && chat.unreadCount > 0" class="unread-text">{{ chat.unreadCount }}</div>
</div>
<div class="chat-right">
<div class="chat-name">

6
im-web/src/store/chatStore.js

@ -196,7 +196,7 @@ export default defineStore('chatStore', {
chat.lastSendTime = msgInfo.sendTime;
chat.sendNickName = msgInfo.sendNickName;
// 未读加1
if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) {
chat.unreadCount++;
}
@ -350,7 +350,6 @@ export default defineStore('chatStore', {
let chat = this.findChat(chatInfo);
if (chat) {
chat.isDnd = isDnd;
chat.unreadCount = 0;
}
},
refreshChats() {
@ -370,9 +369,6 @@ export default defineStore('chatStore', {
chat.isDnd = group.isDnd
}
}
if (chat.isDnd) {
chat.unreadCount = 0;
}
})
// 排序
cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime);

8
im-web/src/view/Home.vue

@ -392,10 +392,6 @@ export default {
location.href = "/";
},
playAudioTip() {
// 线
if (this.chatStore.isLoading()) {
return;
}
//
if (new Date().getTime() - this.lastPlayAudioTime > 1000) {
this.lastPlayAudioTime = new Date().getTime();
@ -439,8 +435,8 @@ export default {
unreadCount() {
let unreadCount = 0;
let chats = this.chatStore.chats;
chats.forEach((chat) => {
if (!chat.delete) {
chats.forEach(chat => {
if (!chat.delete && !chat.isDnd) {
unreadCount += chat.unreadCount
}
});

Loading…
Cancel
Save