Commit ff7d697c by panjiangyi

结束会话

parent aadf43ba
Showing with 32 additions and 25 deletions
...@@ -12,22 +12,14 @@ import chatType from "../xim/chat-type"; ...@@ -12,22 +12,14 @@ import chatType from "../xim/chat-type";
import { Chat as ChatType } from "../xim/models/chat"; import { Chat as ChatType } from "../xim/models/chat";
import xim, { ChatNotifyListener } from "../xim/xim"; import xim, { ChatNotifyListener } from "../xim/xim";
import { ChatMemberType, ChatStatus, ChatStore, ChatStoreState } from "./model"; import { ChatStatus, ChatStore, ChatStoreState } from "./model";
export const ns = ChatStore.ns; export const ns = ChatStore.ns;
const sdk = Chat.getSdk; const sdk = Chat.getSdk;
const UniplatChatModelName = "UniplatChat"; const UniplatChatModelName = "UniplatChat";
const model = () => sdk().model(UniplatChatModelName); const model = () => sdk().model(UniplatChatModelName);
const orgId = Chat.getOrgId;
// const getMyinfo = (function () {
// let data: Index.getUserInfo;
// return async () => {
// if (data != null) return data;
// data = await sdk().getUserInfo();
// return data;
// };
// })();
function uniqueMessages( function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY> messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) { ) {
...@@ -302,7 +294,7 @@ export default { ...@@ -302,7 +294,7 @@ export default {
return { return {
...chat, ...chat,
chat_id: chat.id, chat_id: chat.id,
business_data business_data,
} as ChatType; } as ChatType;
}), }),
total: 9999, total: 9999,
...@@ -369,9 +361,7 @@ export default { ...@@ -369,9 +361,7 @@ export default {
const data = await model() const data = await model()
.action("sendMsg") .action("sendMsg")
.updateInitialParams({ .updateInitialParams({
selected_list: [ selected_list: [{ v: 0, id: Number(uniplatId) }],
{ v: 0, id: Number(uniplatId) },
],
}) })
.addInputs_parameter({ .addInputs_parameter({
LastMsgType: params.msgType, LastMsgType: params.msgType,
...@@ -408,13 +398,21 @@ export default { ...@@ -408,13 +398,21 @@ export default {
{ state, commit, dispatch }, { state, commit, dispatch },
params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0] params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0]
) { ) {
const { id } = await sdk().model(params.modelName).chat(+params.selectedListId).createChat(); const { id } = await sdk()
await new Promise(resolve => setTimeout(resolve, 500)); .model(params.modelName)
.chat(+params.selectedListId)
.createChat();
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const newChatInfo = await getChatModelInfo(params.modelName, params.selectedListId); const newChatInfo = await getChatModelInfo(
params.modelName,
params.selectedListId
);
const roomList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]; const roomList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST];
if (roomList == null) return; if (roomList == null) return;
const newChat = roomList.list.find((k) => k.chat_id === newChatInfo.chat_id); const newChat = roomList.list.find(
(k) => k.chat_id === newChatInfo.chat_id
);
if (newChat == null) return; if (newChat == null) return;
commit(ChatStore.MUTATION_SHOW_CHAT); commit(ChatStore.MUTATION_SHOW_CHAT);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, { await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
...@@ -543,8 +541,7 @@ export default { ...@@ -543,8 +541,7 @@ export default {
const id = Number( const id = Number(
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID] state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]
); );
await sdk() await model()
.model(UniplatChatModelName)
.action("update") .action("update")
.updateInitialParams({ .updateInitialParams({
selected_list: [{ v, id }], selected_list: [{ v, id }],
...@@ -556,7 +553,10 @@ export default { ...@@ -556,7 +553,10 @@ export default {
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0]; const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0];
if (firstChat == null) return; if (firstChat == null) return;
const chatInfo = await getChatModelInfo(firstChat.business_data.model_name, firstChat.business_data.obj_id); const chatInfo = await getChatModelInfo(
firstChat.business_data.model_name,
firstChat.business_data.obj_id
);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, { await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
chatId: firstChat.chat_id, chatId: firstChat.chat_id,
v: chatInfo.uniplat_version, v: chatInfo.uniplat_version,
...@@ -572,7 +572,10 @@ export default { ...@@ -572,7 +572,10 @@ export default {
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id).addMember(uids.map(id => Number(id))); await sdk()
.model(model_name)
.chat(obj_id)
.addMember(uids.map((id) => Number(id)));
await new Promise((resolve) => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS); await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}, },
...@@ -585,7 +588,10 @@ export default { ...@@ -585,7 +588,10 @@ export default {
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id).removeMember(uids.map(id => Number(id))); await sdk()
.model(model_name)
.chat(obj_id)
.removeMember(uids.map((id) => Number(id)));
await new Promise((resolve) => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS); await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}, },
...@@ -613,8 +619,9 @@ export default { ...@@ -613,8 +619,9 @@ export default {
}, },
[ChatStore.GETTER_CURRENT_CURRENT_CHAT](state) { [ChatStore.GETTER_CURRENT_CURRENT_CHAT](state) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const chatList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? []; const chatList =
return chatList.find(chat => chat.chat_id === chatId); state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
return chatList.find((chat) => chat.chat_id === chatId);
}, },
}, },
} as Module<ChatStoreState, RootStoreState>; } as Module<ChatStoreState, RootStoreState>;
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