address things

This commit is contained in:
Sorunome 2020-07-02 10:32:11 +02:00
parent 8f122195c5
commit 7351319f28
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
2 changed files with 18 additions and 8 deletions

View file

@ -91,13 +91,13 @@ class Client {
verificationMethods ??= <KeyVerificationMethod>{}; verificationMethods ??= <KeyVerificationMethod>{};
importantStateEvents ??= <String>{}; importantStateEvents ??= <String>{};
importantStateEvents.addAll([ importantStateEvents.addAll([
'm.room.name', EventTypes.RoomName,
'm.room.avatar', EventTypes.RoomAvatar,
'm.room.message', EventTypes.Message,
'm.room.encrypted', EventTypes.Encrypted,
'm.room.encryption', EventTypes.Encryption,
'm.room.canonical_alias', EventTypes.RoomCanonicalAlias,
'm.room.tombstone', EventTypes.RoomTombstone,
]); ]);
api = MatrixApi(debug: debug, httpClient: httpClient); api = MatrixApi(debug: debug, httpClient: httpClient);
onLoginStateChanged.stream.listen((loginState) { onLoginStateChanged.stream.listen((loginState) {
@ -980,6 +980,16 @@ class Client {
if (event['type'] == EventTypes.Encrypted && encryptionEnabled) { if (event['type'] == EventTypes.Encrypted && encryptionEnabled) {
update = await update.decrypt(room); update = await update.decrypt(room);
} }
if (event['type'] == EventTypes.Message &&
!room.isDirectChat &&
database != null &&
room.getState(EventTypes.RoomMember, event['sender']) == null) {
// In order to correctly render room list previews we need to fetch the member from the database
final user = await database.getUser(id, event['sender'], room);
if (user != null) {
room.setState(user);
}
}
if (type != 'ephemeral' && database != null) { if (type != 'ephemeral' && database != null) {
await database.storeEventUpdate(id, update); await database.storeEventUpdate(id, update);
} }

View file

@ -199,7 +199,7 @@ class Database extends _$Database {
// we limit to only fetching 500 rooms at once. // we limit to only fetching 500 rooms at once.
// This value might be fine-tune-able to be larger (and thus increase performance more for very large accounts), // This value might be fine-tune-able to be larger (and thus increase performance more for very large accounts),
// however this very conservative value should be on the safe side. // however this very conservative value should be on the safe side.
final MAX_ROOMS_PER_QUERY = 500; const MAX_ROOMS_PER_QUERY = 500;
// as we iterate over our entries in separate chunks one-by-one we use an iterator // as we iterate over our entries in separate chunks one-by-one we use an iterator
// which persists accross the chunks, and thus we just re-sume iteration at the place // which persists accross the chunks, and thus we just re-sume iteration at the place
// we prreviously left off. // we prreviously left off.