requestUser method
Requests a missing User for this room. Important for clients using
lazy loading. If the user can't be found this method tries to fetch
the displayname and avatar from the server if requestState
is true.
If that fails, it falls back to requesting the global profile if
requestProfile
is true.
Implementation
Future<User?> requestUser(
String mxID, {
bool ignoreErrors = false,
bool requestState = true,
bool requestProfile = true,
}) async {
assert(mxID.isValidMatrixId);
final parameters = (
mxID: mxID,
ignoreErrors: ignoreErrors,
requestState: requestState,
requestProfile: requestProfile,
);
final cache = _inflightUserRequests[parameters] ??= AsyncCache.ephemeral();
try {
final user = await cache.fetch(() => _requestUser(
mxID,
ignoreErrors: ignoreErrors,
requestState: requestState,
requestProfile: requestProfile,
));
_inflightUserRequests.remove(parameters);
return user;
} catch (_) {
_inflightUserRequests.remove(parameters);
rethrow;
}
}