fix: Don't query /members over and over
This commit is contained in:
parent
f6259efa59
commit
3187275ed7
|
@ -1044,6 +1044,8 @@ class Room {
|
||||||
return userList;
|
return userList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _requestedParticipants = false;
|
||||||
|
|
||||||
/// Request the full list of participants from the server. The local list
|
/// Request the full list of participants from the server. The local list
|
||||||
/// from the store is not complete if the client uses lazy loading.
|
/// from the store is not complete if the client uses lazy loading.
|
||||||
Future<List<User>> requestParticipants() async {
|
Future<List<User>> requestParticipants() async {
|
||||||
|
@ -1054,13 +1056,16 @@ class Room {
|
||||||
setState(user);
|
setState(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (participantListComplete) return getParticipants();
|
if (_requestedParticipants || participantListComplete) {
|
||||||
|
return getParticipants();
|
||||||
|
}
|
||||||
final matrixEvents = await client.requestMembers(id);
|
final matrixEvents = await client.requestMembers(id);
|
||||||
final users =
|
final users =
|
||||||
matrixEvents.map((e) => Event.fromMatrixEvent(e, this).asUser).toList();
|
matrixEvents.map((e) => Event.fromMatrixEvent(e, this).asUser).toList();
|
||||||
for (final user in users) {
|
for (final user in users) {
|
||||||
setState(user); // at *least* cache this in-memory
|
setState(user); // at *least* cache this in-memory
|
||||||
}
|
}
|
||||||
|
_requestedParticipants = true;
|
||||||
users.removeWhere(
|
users.removeWhere(
|
||||||
(u) => [Membership.leave, Membership.ban].contains(u.membership));
|
(u) => [Membership.leave, Membership.ban].contains(u.membership));
|
||||||
return users;
|
return users;
|
||||||
|
|
Loading…
Reference in a new issue