Commit 59cbb6ce by Sixong.Zhu

u

parent ffceeec5
Showing with 15 additions and 16 deletions
......@@ -155,7 +155,6 @@
import avatar from "@/customer-service/components/avatar.vue";
import { chatStore, ChatStore } from "@/customer-service/store/model";
import ximInstance from "../xim/xim";
import { dbController } from "../database";
import ImageMessage from "./message-item/image-message.vue";
import FileMessage from "./message-item/file-message.vue";
import AudioMessage from "./message-item/audio-message.vue";
......
......@@ -232,8 +232,8 @@ export default {
);
const withdraw = hasWithdraw
? newItems
.filter((i) => i.type === MessageType.Withdraw)
.map((i) => +i.msg)
.filter((i) => i.type === MessageType.Withdraw)
.map((i) => +i.msg)
: [];
const filterout = withdraw.length
? newItems.filter((i) => !withdraw.includes(i.id))
......@@ -376,7 +376,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,
......@@ -470,15 +470,10 @@ export default {
}
if (cache && cache.length) {
commit(ChatStore.MUTATION_SAVE_CHAT_LIST, cache);
const ts = cache
.map((i) => Math.max(i.last_msg_ts, i.update_time))
.sort();
const last = ts[ts.length - 1];
const execute = () =>
new Promise<ChatType[]>((resolve, reject) => {
Chat.onReady(() => {
xim.fetchChatListAfter(last)!
xim.fetchChatListAfter(0)
.then((r) => {
const list = filterActiveChats(
r.args[0] as RawChatItem[]
......@@ -495,6 +490,10 @@ export default {
dispatch(
ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT
).finally(resolve);
commit(
ChatStore.MUTATION_SAVE_CHAT_LIST,
cache
);
})
.catch(reject);
});
......@@ -781,7 +780,8 @@ export default {
if (
e.type === MessageType.Withdraw &&
// 这里再取一次当前chatId避免数据和当前不一致
e.chat_id === state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]
e.chat_id ===
state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]
) {
commit(
ChatStore.MUTATION_WITHDRAW,
......@@ -993,7 +993,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);
})
);
......@@ -1250,8 +1250,8 @@ export default {
p.read_count = option.all
? p.total_read_count
: option.readed
? option.readed
: p.read_count + 1;
? option.readed
: p.read_count + 1;
}
}
} else {
......@@ -1260,8 +1260,8 @@ export default {
p.read_count = option.all
? p.total_read_count
: option.readed
? option.readed
: p.read_count + 1;
? option.readed
: p.read_count + 1;
}
}
}
......
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