feat: Display performance warning when requesting more than 100 participants

This commit is contained in:
Krille 2023-05-20 08:19:52 +02:00
parent 9379d419a2
commit 0f36659ba7
No known key found for this signature in database
1 changed files with 11 additions and 1 deletions

View File

@ -1537,7 +1537,8 @@ class Room {
Membership.join,
Membership.invite,
Membership.knock,
]]) async {
],
bool suppressWarning = false]) async {
if (!participantListComplete && partial) {
// we aren't fully loaded, maybe the users are in the database
final users = await client.database?.getUsers(this) ?? [];
@ -1552,6 +1553,15 @@ class Room {
return getParticipants(membershipFilter);
}
final memberCount = summary.mJoinedMemberCount;
if (!suppressWarning && memberCount != null && memberCount > 100) {
Logs().w('''
Loading a list of $memberCount participants for the room $id.
This may affect the performance. Please make sure to not unnecessary
request so many participants or suppress this warning.
''');
}
final matrixEvents = await client.getMembersByRoom(id);
final users = matrixEvents
?.map((e) => Event.fromMatrixEvent(e, this).asUser)