Commit 62ac38f4 by Sixong.Zhu

u

parent 95796600
Showing with 16 additions and 16 deletions
...@@ -32,7 +32,7 @@ function uniqueMessages( ...@@ -32,7 +32,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);
}); });
} }
...@@ -259,10 +259,10 @@ export default { ...@@ -259,10 +259,10 @@ export default {
data: ChatStore.STATE_CHAT_MSG_HISTORY data: ChatStore.STATE_CHAT_MSG_HISTORY
) { ) {
const old = state[ChatStore.STATE_CHAT_MSG_HISTORY] || []; const old = state[ChatStore.STATE_CHAT_MSG_HISTORY] || [];
const chatid = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatid == null) return; if (!chatId) return;
state[ChatStore.STATE_CHAT_MSG_HISTORY] = Object.freeze( state[ChatStore.STATE_CHAT_MSG_HISTORY] = Object.freeze(
filterMessages([...(data || []), ...old], chatid) filterMessages([...(data || []), ...old], chatId)
); );
}, },
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS]( [ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS](
...@@ -362,14 +362,14 @@ export default { ...@@ -362,14 +362,14 @@ 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,
payload: Parameters<ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING>[0] payload: Parameters<ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING>[0]
) => { ) => {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (!chatId) return;
if (payload.chat_id !== chatId) return; if (payload.chat_id !== chatId) return;
const arr = state[ChatStore.STATE_CURRENT_CHAT_INPUTING]; const arr = state[ChatStore.STATE_CURRENT_CHAT_INPUTING];
const eid = payload.eid; const eid = payload.eid;
...@@ -411,8 +411,8 @@ export default { ...@@ -411,8 +411,8 @@ export default {
}, },
[ChatStore.MUTATION_WITHDRAW]: (state, ids: number[]) => { [ChatStore.MUTATION_WITHDRAW]: (state, ids: number[]) => {
const old = state[ChatStore.STATE_CHAT_MSG_HISTORY] || []; const old = state[ChatStore.STATE_CHAT_MSG_HISTORY] || [];
const chatid = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatid == null) return; if (!chatId) return;
state[ChatStore.STATE_CHAT_MSG_HISTORY] = old.filter( state[ChatStore.STATE_CHAT_MSG_HISTORY] = old.filter(
(i) => !ids.includes(i.id) (i) => !ids.includes(i.id)
); );
...@@ -563,7 +563,7 @@ export default { ...@@ -563,7 +563,7 @@ export default {
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
const isMember = state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]; const isMember = state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER];
if (chatId == null) return; if (!chatId) return;
let data: Message[] = []; let data: Message[] = [];
const getMessages = async () => { const getMessages = async () => {
const o = { const o = {
...@@ -600,7 +600,7 @@ export default { ...@@ -600,7 +600,7 @@ export default {
msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID>[0] msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID>[0]
) { ) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (!chatId) return;
const chat = getters[ const chat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -625,7 +625,7 @@ export default { ...@@ -625,7 +625,7 @@ export default {
msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID>[0] msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID>[0]
) { ) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (!chatId) return;
const chat = getters[ const chat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -931,7 +931,7 @@ export default { ...@@ -931,7 +931,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);
}) })
); );
...@@ -1188,8 +1188,8 @@ export default { ...@@ -1188,8 +1188,8 @@ export default {
p.read_count = option.all p.read_count = option.all
? p.total_read_count ? p.total_read_count
: option.readed : option.readed
? option.readed ? option.readed
: p.read_count + 1; : p.read_count + 1;
} }
} }
} else { } else {
...@@ -1198,8 +1198,8 @@ export default { ...@@ -1198,8 +1198,8 @@ export default {
p.read_count = option.all p.read_count = option.all
? p.total_read_count ? p.total_read_count
: option.readed : option.readed
? option.readed ? option.readed
: p.read_count + 1; : 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