Commit 9904992d by Sixong.Zhu

type

parent e2bb38a9
Showing with 17 additions and 16 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);
}); });
} }
...@@ -332,7 +332,7 @@ export default { ...@@ -332,7 +332,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,
...@@ -480,7 +480,7 @@ export default { ...@@ -480,7 +480,7 @@ export default {
}, },
async [ChatStore.ACTION_GET_CHAT_MESSAGES]({ state, commit, getters }) { async [ChatStore.ACTION_GET_CHAT_MESSAGES]({ state, commit, getters }) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] 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 == null) return;
let data: Message[] = []; let data: Message[] = [];
...@@ -520,7 +520,7 @@ export default { ...@@ -520,7 +520,7 @@ export default {
) { ) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (chatId == null) return;
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
const o = { const o = {
model: chat.model_name, model: chat.model_name,
obj: chat.obj_id, obj: chat.obj_id,
...@@ -543,7 +543,7 @@ export default { ...@@ -543,7 +543,7 @@ export default {
) { ) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (chatId == null) return;
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
const o = { const o = {
model: chat.model_name, model: chat.model_name,
obj: chat.obj_id, obj: chat.obj_id,
...@@ -570,7 +570,7 @@ export default { ...@@ -570,7 +570,7 @@ export default {
} }
} }
try { try {
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
const data = await Chat.getSdk() const data = await Chat.getSdk()
.model(chat.model_name) .model(chat.model_name)
.chat(chat.obj_id, orgId()) .chat(chat.obj_id, orgId())
...@@ -665,7 +665,7 @@ export default { ...@@ -665,7 +665,7 @@ export default {
if (msgs == null) return; if (msgs == null) return;
const oldestMsgId = msgs[0].id - 1; const oldestMsgId = msgs[0].id - 1;
const lastMsgId = msgs[msgs.length - 1].id + 1; const lastMsgId = msgs[msgs.length - 1].id + 1;
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
const o = { const o = {
model: chat.model_name, model: chat.model_name,
obj: chat.obj_id, obj: chat.obj_id,
...@@ -820,7 +820,7 @@ export default { ...@@ -820,7 +820,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);
}) })
); );
...@@ -854,7 +854,7 @@ export default { ...@@ -854,7 +854,7 @@ export default {
); );
}, },
async [ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -869,7 +869,7 @@ export default { ...@@ -869,7 +869,7 @@ export default {
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async [ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -884,7 +884,7 @@ export default { ...@@ -884,7 +884,7 @@ export default {
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async [ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -892,6 +892,7 @@ export default { ...@@ -892,6 +892,7 @@ export default {
) { ) {
return Promise.reject(); return Promise.reject();
} }
await dbController.removeChatFromList(currentChat.id);
return await Chat.getSdk() return await Chat.getSdk()
.model(currentChat.model_name) .model(currentChat.model_name)
.chat(currentChat.obj_id, orgId()) .chat(currentChat.obj_id, orgId())
...@@ -899,7 +900,7 @@ export default { ...@@ -899,7 +900,7 @@ export default {
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async [ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -917,7 +918,7 @@ export default { ...@@ -917,7 +918,7 @@ export default {
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -935,7 +936,7 @@ export default { ...@@ -935,7 +936,7 @@ export default {
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_MEMBER>[0] uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_MEMBER>[0]
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -953,7 +954,7 @@ export default { ...@@ -953,7 +954,7 @@ export default {
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_CS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_CS>[0]
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
...@@ -971,7 +972,7 @@ export default { ...@@ -971,7 +972,7 @@ export default {
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0] uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0]
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType;
if ( if (
!currentChat || !currentChat ||
!currentChat.model_name || !currentChat.model_name ||
......
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