From d921f3873431cb2150df1e7f94a2571625fe90f0 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 1 Sep 2021 14:00:22 +0200 Subject: [PATCH] feat: Pin invited rooms Invitations should always be on top of the room list. This makes it an optional parameter now which defaults to true. --- lib/src/client.dart | 4 ++++ lib/src/room.dart | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 32fe2cd7..cb167b0c 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -160,6 +160,7 @@ class Client extends MatrixApi { this.importantStateEvents, this.roomPreviewLastEvents, this.pinUnreadRooms = false, + this.pinInvitedRooms = true, this.sendMessageTimeoutSeconds = 60, this.requestHistoryOnLimitedTimeline = false, this.supportedLoginTypes, @@ -1576,6 +1577,9 @@ sort order of ${prevState.sortOrder}. This should never happen...'''); /// If `true` then unread rooms are pinned at the top of the room list. bool pinUnreadRooms; + /// If `true` then unread rooms are pinned at the top of the room list. + bool pinInvitedRooms; + /// The compare function how the rooms should be sorted internally. By default /// rooms are sorted by timestamp of the last m.room.message event or the last /// event if there is no known message. diff --git a/lib/src/room.dart b/lib/src/room.dart index 8d5c0022..74bdcaa0 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -545,7 +545,9 @@ class Room { } /// Returns true if this room has a m.favourite tag. - bool get isFavourite => tags[TagType.favourite] != null; + bool get isFavourite => + tags[TagType.favourite] != null || + (client.pinInvitedRooms && membership == Membership.invite); /// Sets the m.favourite tag for this room. Future setFavourite(bool favourite) =>