Commit aadf43ba by panjiangyi

添加和删除成员新接口

parent 63ec25ed
Showing with 23 additions and 51 deletions
......@@ -82,9 +82,14 @@ export default class ChatTitle extends Vue {
}
private async addMember(users: string[], done: () => void) {
await this._addMember(users);
done();
this.hideAddMember();
try {
await this._addMember(users);
this.hideAddMember();
} catch (error) {
console.error(error);
} finally {
done();
}
}
}
</script>
......
......@@ -408,19 +408,14 @@ export default {
{ state, commit, dispatch },
params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0]
) {
const { id } = await sdk().model(params.modelName).createChat({
detailId: +params.selectedListId
});
const { id } = await sdk().model(params.modelName).chat(+params.selectedListId).createChat();
await new Promise(resolve => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
console.log("fuck 0");
const newChatInfo = await getChatModelInfo(params.modelName, params.selectedListId);
const roomList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST];
if (roomList == null) return;
console.log("fuck 1");
const newChat = roomList.list.find((k) => k.chat_id === newChatInfo.chat_id);
if (newChat == null) return;
console.log("fuck 2");
commit(ChatStore.MUTATION_SHOW_CHAT);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
chatId: newChat.chat_id,
......@@ -569,56 +564,28 @@ export default {
});
},
async [ChatStore.ACTION_CHAT_ADD_MEMBERS](
{ state, dispatch },
{ getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
) {
const v = state[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION];
if (v == null) return;
const id = Number(
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]
);
const action = sdk().model(UniplatChatModelName).action("update");
action.updateInitialParams({
selected_list: [{ v, id }],
});
const detailManager = await action.getDetailParametersManagerByName(
"UniplatChatMember"
);
uids.forEach((Uid) => {
detailManager.add({
OrgId: orgId(),
Uid,
type: ChatMemberType.member,
});
});
detailManager.uniqBy("Uid");
detailManager.done();
await action.execute();
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return;
if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id).addMember(uids.map(id => Number(id)));
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
async [ChatStore.ACTION_CHAT_REMOVE_MEMBER](
{ state, dispatch },
{ getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_MEMBER>[0]
) {
const v = state[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION];
if (v == null) return;
const id = Number(
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]
);
const action = sdk().model(UniplatChatModelName).action("update");
action.updateInitialParams({
selected_list: [{ v, id }],
});
const detailManager = await action.getDetailParametersManagerByName(
"UniplatChatMember"
);
uids.forEach((Uid) => {
detailManager.deleteByPropertyValue("Uid", Uid);
});
detailManager.uniqBy("Uid");
detailManager.done();
await action.execute();
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return;
if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id).removeMember(uids.map(id => Number(id)));
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
......
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