Commit 57bf14e5 by Sixong.Zhu

update

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