fix: own profile containing mxid
There are a few ways to fix this. We could skip events, where we don't have the state in memory yet or always do a /profile request and cache that. I chose to go with loading the event from the database if necessary. If we have a room in the db, we should have our memberevent in the db. In some cases we might not (if the server thinks our memberevent is super redundant), but I think the spec doesn't really allow that and it doesn't happen in practice. And even if it would, we probably would want our member event ASAP. And if we have no rooms, we fetch it from the server as before instead of constructing a member with an MXID as the username. fixes https://gitlab.com/famedly/company/frontend/frontend-issue-inbox/-/issues/65
This commit is contained in:
parent
d047678971
commit
83298cc98b
|
|
@ -675,12 +675,14 @@ class Client extends MatrixApi {
|
|||
if (rooms.isNotEmpty) {
|
||||
final profileSet = <Profile>{};
|
||||
for (final room in rooms) {
|
||||
final user = room.getUserByMXIDSync(userID!);
|
||||
profileSet.add(Profile(
|
||||
avatarUrl: user.avatarUrl,
|
||||
displayName: user.displayName,
|
||||
userId: user.id,
|
||||
));
|
||||
final user = await room.requestUser(userID!);
|
||||
if (user != null) {
|
||||
profileSet.add(Profile(
|
||||
avatarUrl: user.avatarUrl,
|
||||
displayName: user.displayName,
|
||||
userId: user.id,
|
||||
));
|
||||
}
|
||||
}
|
||||
if (profileSet.length == 1) return profileSet.single;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue