From c194ddee66c1cf142c37f9130d69827eb0f91a7e Mon Sep 17 00:00:00 2001 From: Krille Date: Fri, 28 Feb 2025 11:24:46 +0100 Subject: [PATCH] refactor: Make markUnread a noop if unread is already as intendend and throw exception if room membership is not join --- lib/src/room.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/room.dart b/lib/src/room.dart index dc1d0267..0591b77c 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -566,6 +566,12 @@ class Room { /// this works if there is no connection to the homeserver. This does **not** /// set a read marker! Future 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(); await _handleFakeSync( SyncUpdate(