loadHeroUsers method
Returns the heroes as User
objects.
This is very useful if you want to make sure that all users are loaded
from the database, that you need to correctly calculate the displayname
and the avatar of the room.
Implementation
Future<List<User>> loadHeroUsers() async {
// For invite rooms request own user and invitor.
if (membership == Membership.invite) {
final ownUser = await requestUser(client.userID!, requestProfile: false);
if (ownUser != null) await requestUser(ownUser.senderId);
}
var heroes = summary.mHeroes;
if (heroes == null) {
final directChatMatrixID = this.directChatMatrixID;
if (directChatMatrixID != null) {
heroes = [directChatMatrixID];
}
}
if (heroes == null) return [];
return await Future.wait(heroes.map((hero) async =>
(await requestUser(
hero,
ignoreErrors: true,
)) ??
User(hero, room: this)));
}