diff --git a/frontend/src/api/groups.ts b/frontend/src/api/groups.ts index 8068cc9..bfbb8fe 100644 --- a/frontend/src/api/groups.ts +++ b/frontend/src/api/groups.ts @@ -25,14 +25,16 @@ export async function getUserGroups(): Promise { if (!user) return [] return pb.collection('groups').getList(1, 50, { - filter: `members ~ "${user.id}"` + filter: `members ~ "${user.id}"`, + $autoCancel: false }).then(res => res.items as unknown as Group[]) } // 获取群组详情 export async function getGroup(groupId: string): Promise { return pb.collection('groups').getOne(groupId, { - expand: 'members' + expand: 'members', + $autoCancel: false }) as unknown as Group } @@ -82,7 +84,8 @@ export async function getGroupJoinRequests(groupId: string): Promise { const result = await pb.collection('join_requests').getList(1, 50, { filter: `group.owner="${user.id}" && status="pending"`, sort: '-created', - expand: 'user,group' + expand: 'user,group', + $autoCancel: false }) return result.items as unknown as JoinRequest[] } @@ -184,10 +188,17 @@ export function subscribeJoinRequests(groupId: string, callback: (request: JoinR // 获取群组成员 export async function getGroupMembers(groupId: string) { const group = await getGroup(groupId) + + if (group.expand?.members) { + return group.expand.members + } + const members = group.members as string[] + if (!members || members.length === 0) return [] const users = await pb.collection('users').getList(1, 50, { - filter: members.map(id => `id="${id}"`).join(' || ') + filter: members.map(id => `id="${id}"`).join(' || '), + $autoCancel: false }) return users.items