Commit 2b02de5c by panjiangyi

成员名字

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