fix(web): harden chat info profile loading for partial failures
Some checks are pending
CI / test (push) Has started running
Some checks are pending
CI / test (push) Has started running
This commit is contained in:
@@ -155,9 +155,11 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) {
|
||||
}
|
||||
}
|
||||
if (missingIds.length) {
|
||||
const profiles = await Promise.all(missingIds.map((id) => getUserById(id)));
|
||||
const profiles = await Promise.allSettled(missingIds.map((id) => getUserById(id)));
|
||||
for (const profile of profiles) {
|
||||
byId[profile.id] = profile;
|
||||
if (profile.status === "fulfilled") {
|
||||
byId[profile.value.id] = profile.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
setMemberUsers(byId);
|
||||
@@ -169,10 +171,12 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) {
|
||||
const nextBans = await listChatBans(targetChatId);
|
||||
setBans(nextBans);
|
||||
const ids = [...new Set(nextBans.flatMap((item) => [item.user_id, item.banned_by_user_id]))];
|
||||
const profiles = await Promise.all(ids.map((id) => getUserById(id)));
|
||||
const profiles = await Promise.allSettled(ids.map((id) => getUserById(id)));
|
||||
const byId: Record<number, AuthUser> = {};
|
||||
for (const profile of profiles) {
|
||||
byId[profile.id] = profile;
|
||||
if (profile.status === "fulfilled") {
|
||||
byId[profile.value.id] = profile.value;
|
||||
}
|
||||
}
|
||||
setBannedUsers(byId);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user