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>{};
importantStateEvents ??= <String>{};
importantStateEvents.addAll([
'm.room.name',
'm.room.avatar',
'm.room.message',
'm.room.encrypted',
'm.room.encryption',
'm.room.canonical_alias',
'm.room.tombstone',
EventTypes.RoomName,
EventTypes.RoomAvatar,
EventTypes.Message,
EventTypes.Encrypted,
EventTypes.Encryption,
EventTypes.RoomCanonicalAlias,
EventTypes.RoomTombstone,
]);
api = MatrixApi(debug: debug, httpClient: httpClient);
onLoginStateChanged.stream.listen((loginState) {
@ -980,6 +980,16 @@ class Client {
if (event['type'] == EventTypes.Encrypted && encryptionEnabled) {
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) {
await database.storeEventUpdate(id, update);
}

View file

@ -199,7 +199,7 @@ class Database extends _$Database {
// 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),
// 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
// which persists accross the chunks, and thus we just re-sume iteration at the place
// we prreviously left off.