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. 8
      im-uniapp/components/chat-item/chat-item.vue
  2. 26
      im-uniapp/pages/chat/chat-box.vue
  3. 2
      im-uniapp/pages/chat/chat.vue
  4. 6
      im-uniapp/store/chatStore.js
  5. 31
      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

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

@ -17,8 +17,8 @@
<view class="chat-send-name" v-if="isShowSendName">{{ chat.sendNickName + ':&nbsp;' }}</view> <view class="chat-send-name" v-if="isShowSendName">{{ chat.sendNickName + ':&nbsp;' }}</view>
<rich-text class="chat-content-text" <rich-text class="chat-content-text"
:nodes="$emo.transform(chat.lastContent,'emoji-small')"></rich-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> <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> </view>
</view> </view>
@ -170,9 +170,11 @@ export default {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.icon {
font-size: $im-font-size;
}
} }
} }
} }

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

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

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

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

6
im-uniapp/store/chatStore.js

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

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

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

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

@ -3,7 +3,7 @@
<div class="chat-left"> <div class="chat-left">
<head-image :url="chat.headImage" :name="chat.showName" :size="42" <head-image :url="chat.headImage" :name="chat.showName" :size="42"
:id="chat.type == 'PRIVATE' ? chat.targetId : 0" :isShowUserInfo="false"></head-image> :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>
<div class="chat-right"> <div class="chat-right">
<div class="chat-name"> <div class="chat-name">

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

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

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

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

Loading…
Cancel
Save