Commit 2b02de5c by panjiangyi

成员名字

parent 803da04e
......@@ -5,6 +5,7 @@ import { ChatMember } from "../model";
import { isAccessibleUrl } from "../service/tools";
import { unique } from "../utils";
import { decode } from "../utils/jwt";
import { getUserInfo } from "../utils/user-info";
import Chat from "../xim";
import chatType from "../xim/chat-type";
import xim, { ChatNotifyListener } from "../xim/xim";
......@@ -548,14 +549,10 @@ export default {
chatMembers.map(async (member) => {
let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number];
try {
const info = await sdk()
.model("user")
.detail(member.eid)
.query();
const data = await getUserInfo(member.eid);
result = {
...member,
name: info.row.first_name.value as string,
phone: info.row.last_name.value as string,
...data,
};
} catch (error) {
// eslint-disable-next-line no-console
......@@ -621,7 +618,7 @@ export default {
});
detailManager.done();
await action.execute();
await new Promise(resolve => setTimeout(resolve, 500));
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
},
......
import Chat from "../xim";
export type UserMapping = {
[eid: string]: {
name: string;
phone: string;
};
};
const userMapping: UserMapping = {};
export const getUserMapping = () => userMapping;
export async function getUserInfo(eid: string) {
if (userMapping[eid] != null) return userMapping[eid];
const info = await Chat.getSdk().model("user").detail(eid).query();
const data = {
name: info.row.first_name.value as string,
phone: info.row.last_name.value as string,
};
userMapping[eid] = data;
return data;
}
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