Merge pull request #2041 from famedly/krille/refactor-mark-unread

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-chan 2025-02-28 14:30:47 +01:00 committed by GitHub
commit f76210d99b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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(