Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class Client extends MatrixApi {

final Duration sendTimelineEventTimeout;

final bool autoRequestProfileForMissingUsers;
final bool getDisplayNameAndAvatarFromPrevContent;

/// The timeout until a typing indicator gets removed automatically.
final Duration typingIndicatorTimeout;

Expand Down Expand Up @@ -243,6 +246,15 @@ class Client extends MatrixApi {
this.dehydratedDeviceDisplayName = 'Dehydrated Device',
RoomSorter? customRoomSorter,
this.contentScannerConfig,

/// Whether the app automatically requests the profile for users which have
/// no filled out member state in a room. This is e.g. the case for left
/// or banned users.
this.autoRequestProfileForMissingUsers = true,

/// Whether the app should get DisplayName and Avatar also from the
/// previous content of a member state event.
this.getDisplayNameAndAvatarFromPrevContent = true,
}) : _database = database,
syncFilter =
syncFilter ??
Expand Down
8 changes: 5 additions & 3 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2145,15 +2145,16 @@ class Room {
String mxID, {
bool ignoreErrors = false,
bool requestState = true,
bool requestProfile = true,
bool? requestProfile,
}) async {
assert(mxID.isValidMatrixIdStrict());

final parameters = (
mxID: mxID,
ignoreErrors: ignoreErrors,
requestState: requestState,
requestProfile: requestProfile,
requestProfile:
requestProfile ?? client.autoRequestProfileForMissingUsers,
);

final cache = _inflightUserRequests[parameters] ??= AsyncCache.ephemeral();
Expand All @@ -2164,7 +2165,8 @@ class Room {
mxID,
ignoreErrors: ignoreErrors,
requestState: requestState,
requestProfile: requestProfile,
requestProfile:
requestProfile ?? client.autoRequestProfileForMissingUsers,
),
);
_inflightUserRequests.remove(parameters);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class User extends StrippedStateEvent {
/// The displayname of the user if the user has set one.
String? get displayName =>
content.tryGet<String>('displayname') ??
(membership == Membership.join
(membership == Membership.join ||
!room.client.getDisplayNameAndAvatarFromPrevContent
? null
: prevContent?.tryGet<String>('displayname'));

Expand All @@ -80,7 +81,8 @@ class User extends StrippedStateEvent {
Uri? get avatarUrl {
final uri =
content.tryGet<String>('avatar_url') ??
(membership == Membership.join
(membership == Membership.join ||
!room.client.getDisplayNameAndAvatarFromPrevContent
? null
: prevContent?.tryGet<String>('avatar_url'));
return uri == null ? null : Uri.tryParse(uri);
Expand Down
Loading