famedly / matrix-dart-sdk

Matrix SDK written in pure Dart.
GNU Affero General Public License v3.0
52 stars 30 forks source link

refactor: Cache direct chat matrix ID #1791

Closed krille-chan closed 3 months ago

krille-chan commented 3 months ago

The direct chat account data content is a map from matrixId to roomId(s). If we want to find the roomId for a given userId, then this is not a problem. But the other way around, if we want to check if a given roomId is a direct chat or not, needs to process all entries which can be hundreds. Doing this very often in an app costs a lot of performance. This adds a simple cache in the room object and validates the cache every time to make this more efficient.