Commit 088c2b0c by Sixong.Zhu

update check

parent a24581f5
Showing with 6 additions and 3 deletions
...@@ -31,7 +31,7 @@ function uniqueMessages( ...@@ -31,7 +31,7 @@ function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY> messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) { ) {
const arr = [...messages]; const arr = [...messages];
return unique(arr, function (item, all) { return unique(arr, function(item, all) {
return all.findIndex((k) => k.id === item.id); return all.findIndex((k) => k.id === item.id);
}); });
} }
...@@ -112,12 +112,15 @@ const filterActiveChats = (items: RawChatItem[]) => { ...@@ -112,12 +112,15 @@ const filterActiveChats = (items: RawChatItem[]) => {
}; };
export function getLastMessageId(msgs: Message[] | any) { export function getLastMessageId(msgs: Message[] | any) {
if (msgs && msgs.length) {
const last = msgs[msgs.length - 1]; const last = msgs[msgs.length - 1];
let id = last.id; let id = last.id;
if (id < 0) { if (id < 0) {
id = Math.max(...msgs.map((i: any) => i.id)); id = Math.max(...msgs.map((i: any) => i.id));
} }
return id; return id;
}
return 0;
} }
export default { export default {
...@@ -334,7 +337,7 @@ export default { ...@@ -334,7 +337,7 @@ export default {
state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current]; 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 } = {}; const setTimeoutId: { [key: string]: number } = {};
return ( return (
state: ChatStoreState, state: ChatStoreState,
...@@ -838,7 +841,7 @@ export default { ...@@ -838,7 +841,7 @@ export default {
} }
commit( commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS, ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) { unique(newChatMembers, function(item, all) {
return all.findIndex((k) => k.eid === item.eid); 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