Commit 57bf14e5 by Sixong.Zhu

update

parent 7e385edb
Showing with 7 additions and 6 deletions
......@@ -645,14 +645,14 @@ export default {
state,
getters,
}) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const onNewMsg = (e: Message) => {
// 这里再取一次当前chatId避免数据和当前不一致
const current = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const thenAction = () => {
if (
e.type === MessageType.Withdraw &&
// 这里再取一次当前chatId避免数据和当前不一致
e.chat_id ===
state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]
e.chat_id === current
) {
commit(
ChatStore.MUTATION_WITHDRAW,
......@@ -661,7 +661,7 @@ export default {
}
const scroll = () =>
state[ChatStore.STATE_FUNC_ON_NEW_MSG](e);
if (e.chat_id === chatId) {
if (e.chat_id === current) {
dispatch(ChatStore.ACTION_GET_FRESH_MESSAGE).finally(
() => scroll()
);
......@@ -669,7 +669,7 @@ export default {
scroll();
}
};
if (e.type === MessageType.Withdraw) {
if (e.type === MessageType.Withdraw && current) {
dbController
.removeMessage(e.chat_id, xim.withDrawMsgHandle(e))
.finally(() => thenAction());
......@@ -677,6 +677,7 @@ export default {
thenAction();
}
};
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (!chatId) {
xim.off("msg", onNewMsg);
xim.on("msg", onNewMsg);
......
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