Browse Source

!150 修复吞消息的bug

Merge pull request !150 from blue/v_3.0.0
master
blue 10 months ago
committed by Gitee
parent
commit
f2bbe0ef35
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
  1. 15
      im-uniapp/store/chatStore.js
  2. 12
      im-web/src/store/chatStore.js

15
im-uniapp/store/chatStore.js

@ -374,7 +374,6 @@ export default defineStore('chatStore', {
this.chats.forEach((chat) => { this.chats.forEach((chat) => {
let chatKey = `${key}-${chat.type}-${chat.targetId}` let chatKey = `${key}-${chat.type}-${chat.targetId}`
if (!chat.stored) { if (!chat.stored) {
chat.stored = true;
if (chat.delete) { if (chat.delete) {
uni.removeStorageSync(chatKey); uni.removeStorageSync(chatKey);
} else { } else {
@ -386,15 +385,11 @@ export default defineStore('chatStore', {
} }
// 存储热消息 // 存储热消息
let hotKey = chatKey + '-hot'; let hotKey = chatKey + '-hot';
if (chat.messages.length > chat.hotMinIdx) { let hotChat = Object.assign({}, chat);
let hotChat = Object.assign({}, chat); hotChat.messages = chat.messages.slice(chat.hotMinIdx)
hotChat.messages = chat.messages.slice(chat.hotMinIdx) uni.setStorageSync(hotKey, hotChat);
uni.setStorageSync(hotKey, hotChat);
console.log("热数据:",hotChat.messages.length)
} else {
uni.removeStorageSync(hotKey);
}
} }
chat.stored = true;
} }
if (!chat.delete) { if (!chat.delete) {
chatKeys.push(chatKey); chatKeys.push(chatKey);
@ -429,7 +424,7 @@ export default defineStore('chatStore', {
chatsData.chatKeys.forEach(key => { chatsData.chatKeys.forEach(key => {
let coldChat = uni.getStorageSync(key); let coldChat = uni.getStorageSync(key);
let hotChat = uni.getStorageSync(key + '-hot'); let hotChat = uni.getStorageSync(key + '-hot');
if (!coldChat && hotChat) { if (!coldChat && !hotChat) {
return; return;
} }
// 冷热消息合并 // 冷热消息合并

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

@ -370,7 +370,6 @@ export default defineStore('chatStore', {
// 只存储有改动的会话 // 只存储有改动的会话
let chatKey = `${key}-${chat.type}-${chat.targetId}` let chatKey = `${key}-${chat.type}-${chat.targetId}`
if (!chat.stored) { if (!chat.stored) {
chat.stored = true;
if (chat.delete) { if (chat.delete) {
localForage.removeItem(chatKey); localForage.removeItem(chatKey);
} else { } else {
@ -382,14 +381,11 @@ export default defineStore('chatStore', {
} }
// 存储热消息 // 存储热消息
let hotKey = chatKey + '-hot'; let hotKey = chatKey + '-hot';
if (chat.messages.length > chat.hotMinIdx) { let hotChat = Object.assign({}, chat);
let hotChat = Object.assign({}, chat); hotChat.messages = chat.messages.slice(chat.hotMinIdx)
hotChat.messages = chat.messages.slice(chat.hotMinIdx) localForage.setItem(hotKey, hotChat)
localForage.setItem(hotKey, hotChat)
} else {
localForage.removeItem(hotKey);
}
} }
chat.stored = true;
} }
if (!chat.delete) { if (!chat.delete) {
chatKeys.push(chatKey); chatKeys.push(chatKey);

Loading…
Cancel
Save