Commit fea0bdc8 by Sixong.Zhu

event

parent add19259
Showing with 3 additions and 8 deletions
...@@ -42,7 +42,7 @@ function filterMessages( ...@@ -42,7 +42,7 @@ function filterMessages(
); );
} }
const removeRegisterChatEvents: (() => void)[] = []; let removeRegisterChatEvents: (() => void)[] = [];
async function preCacheImgs(msgs: any[]) { async function preCacheImgs(msgs: any[]) {
await Promise.all( await Promise.all(
...@@ -541,18 +541,12 @@ export default { ...@@ -541,18 +541,12 @@ export default {
} }
state[ChatStore.STATE_FUNC_ON_NEW_MSG](e); state[ChatStore.STATE_FUNC_ON_NEW_MSG](e);
}; };
if (chatId == null) { if (!chatId) {
xim.off("msg", onNewMsg); xim.off("msg", onNewMsg);
xim.on("msg", onNewMsg); xim.on("msg", onNewMsg);
return; return;
} }
const onMsgRead: ChatNotifyListener = async (e) => { const onMsgRead: ChatNotifyListener = async (e) => {
if (
process.env.VUE_APP_API_CLIENT_ID !==
"teamix-fast-service-merchant"
) {
return;
}
if (chatId !== e.chat_id) return; if (chatId !== e.chat_id) return;
const msgs = state[ChatStore.STATE_CHAT_MSG_HISTORY]; const msgs = state[ChatStore.STATE_CHAT_MSG_HISTORY];
if (msgs == null) return; if (msgs == null) return;
...@@ -655,6 +649,7 @@ export default { ...@@ -655,6 +649,7 @@ export default {
commit(ChatStore.MUTATION_INITING_CHAT); commit(ChatStore.MUTATION_INITING_CHAT);
removeRegisterChatEvents.forEach((k) => k()); removeRegisterChatEvents.forEach((k) => k());
removeRegisterChatEvents = [];
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS); await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
await Promise.all([ await Promise.all([
dispatch(ChatStore.ACTION_REGISTER_EVENT), dispatch(ChatStore.ACTION_REGISTER_EVENT),
......
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