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 <the-one@with-the-braid.cf>
This commit is contained in:
TheOneWithTheBraid 2022-10-26 09:31:18 +02:00
parent c436a86915
commit ed7913e710
2 changed files with 7 additions and 1 deletions

View File

@ -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<SyncUpdate> 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;

View File

@ -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(