Commit 0f48ef0a by Sixong.Zhu

自动校准消息

parent 1d90677b
Showing with 21 additions and 0 deletions
...@@ -392,6 +392,26 @@ export default { ...@@ -392,6 +392,26 @@ export default {
loadingChatList = true; loadingChatList = true;
const checkCurrentChat = (items: ChatType[]) => {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId) {
const t = items.find((i) => i.chat_id === chatId);
if (t) {
const msgs = state[ChatStore.STATE_CHAT_MSG_HISTORY];
if (msgs) {
const last = msgs[msgs.length - 1];
// 如果会话列表里面返回的最后消息时间或id大于当前会话缓存的信息,获取最新消息
if (t.last_msg_ts > last.ts || t.msg_id > last.id) {
dispatch(
ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID,
last.id
);
}
}
}
}
};
const execute = () => const execute = () =>
new Promise<ChatType[]>((resolve, reject) => { new Promise<ChatType[]>((resolve, reject) => {
Chat.onReady(() => { Chat.onReady(() => {
...@@ -414,6 +434,7 @@ export default { ...@@ -414,6 +434,7 @@ export default {
dispatch( dispatch(
ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT
); );
checkCurrentChat(items);
resolve(items); resolve(items);
}) })
.catch(reject); .catch(reject);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment