Commit 00d93de0 by Sixong.Zhu

u

parent 2b323c6f
Showing with 3 additions and 12 deletions
...@@ -419,7 +419,7 @@ export default { ...@@ -419,7 +419,7 @@ export default {
}, },
}, },
actions: { actions: {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, state }) { async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, dispatch }) {
commit(ChatStore.MUTATION_SAVE_MYSELF_ID); commit(ChatStore.MUTATION_SAVE_MYSELF_ID);
if (loadingChatList) { if (loadingChatList) {
...@@ -453,15 +453,6 @@ export default { ...@@ -453,15 +453,6 @@ export default {
} }
} }
const buildUnreadMessage = (items: ChatType[]) => {
let sum = 0;
items.forEach((i) => (sum += i.unread_msg_count));
state[ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT] = sum;
return items.sort((x, y) =>
x.last_msg_ts < y.last_msg_ts ? 1 : -1
);
};
if (cache && cache.length) { if (cache && cache.length) {
commit(ChatStore.MUTATION_SAVE_CHAT_LIST, cache); commit(ChatStore.MUTATION_SAVE_CHAT_LIST, cache);
const ts = cache const ts = cache
...@@ -485,7 +476,7 @@ export default { ...@@ -485,7 +476,7 @@ export default {
items items
); );
} }
resolve(buildUnreadMessage(cache)); dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT).finally(resolve);
}) })
.catch(reject); .catch(reject);
}); });
...@@ -513,7 +504,7 @@ export default { ...@@ -513,7 +504,7 @@ export default {
ChatStore.MUTATION_SAVE_CHAT_LIST, ChatStore.MUTATION_SAVE_CHAT_LIST,
items items
); );
resolve(buildUnreadMessage(items)); dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT).finally(resolve);
}) })
.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