From ed7913e71033a5f3e78b924192f2624645fe1a10 Mon Sep 17 00:00:00 2001 From: TheOneWithTheBraid Date: Wed, 26 Oct 2022 09:31:18 +0200 Subject: [PATCH] feat: introduce hightlighted room getter - adds `Room.isUnreadOrInvited` extending `Room.isUnread` to invited rooms This is some high-level abstraction simplifying computation of unread room badges / notifications. Related: https://gitlab.com/groups/famedly/company/-/epics/28 Signed-off-by: TheOneWithTheBraid --- lib/src/room.dart | 5 +++++ test/room_test.dart | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 5865fec2..0ed156ce 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -530,6 +530,10 @@ class Room { /// in muted rooms, use [hasNewMessages]. bool get isUnread => notificationCount > 0 || markedUnread; + /// Returns true if this room is to be marked as unread. This extends + /// [isUnread] to rooms with [Membership.invite]. + bool get isUnreadOrInvited => isUnread || membership == Membership.invite; + @Deprecated('Use waitForRoomInSync() instead') Future get waitForSync => waitForRoomInSync(); @@ -1689,6 +1693,7 @@ class Room { bool get canCreateGroupCall => canChangeStateEvent('org.matrix.msc3401.call') && groupCallsEnabled; + bool get canJoinGroupCall => canChangeStateEvent('org.matrix.msc3401.call.member') && groupCallsEnabled; diff --git a/test/room_test.dart b/test/room_test.dart index 8fe18f5a..98bf0bb7 100644 --- a/test/room_test.dart +++ b/test/room_test.dart @@ -189,7 +189,8 @@ void main() { stateKey: '', ), ); - expect(room.hasNewMessages, true); + expect(room.hasNewMessages, isTrue); + expect(room.isUnreadOrInvited, isTrue); expect(room.lastEvent?.body, 'cd'); room.setState( Event(