Commit 52f58fa8 by Sixong.Zhu

整合已读逻辑

parent 9db323f7
Showing with 11 additions and 4 deletions
......@@ -32,7 +32,7 @@ function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) {
const arr = [...messages];
return unique(arr, function (item, all) {
return unique(arr, function(item, all) {
return all.findIndex((k) => k.id === item.id);
});
}
......@@ -374,7 +374,7 @@ export default {
state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current];
}
},
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function () {
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function() {
const setTimeoutId: { [key: string]: number } = {};
return (
state: ChatStoreState,
......@@ -588,7 +588,14 @@ export default {
.updateChat4UnreadCount(p.chat, p.unread)
.then(() =>
dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT)
);
).finally(() => {
if (!p.unread) {
const messages = state[ChatStore.STATE_CHAT_MSG_HISTORY];
if (messages && messages.length) {
xim.setRead(p.chat, messages[0].id, messages[messages.length - 1].id);
}
}
});
},
async [ChatStore.ACTION_GET_CHAT_MESSAGES]({ state, commit, getters }) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
......@@ -974,7 +981,7 @@ export default {
commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) {
unique(newChatMembers, function(item, all) {
return all.findIndex((k) => k.eid === item.eid);
})
);
......
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