refactor: Make markUnread a noop if unread is already as intendend and throw exception if room membership is not join

This commit is contained in:
Krille 2025-02-28 11:24:46 +01:00
parent 352b3fa68b
commit c194ddee66
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 6 additions and 0 deletions

View File

@ -566,6 +566,12 @@ class Room {
/// this works if there is no connection to the homeserver. This does **not** /// this works if there is no connection to the homeserver. This does **not**
/// set a read marker! /// set a read marker!
Future<void> markUnread(bool unread) async { Future<void> markUnread(bool unread) async {
if (unread == markedUnread) return;
if (membership != Membership.join) {
throw Exception(
'Can not markUnread on a room with membership $membership',
);
}
final content = MarkedUnread(unread).toJson(); final content = MarkedUnread(unread).toJson();
await _handleFakeSync( await _handleFakeSync(
SyncUpdate( SyncUpdate(