From 9a594824bb911643fb744816e23ba7a9d5ba00a9 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 14 Feb 2022 11:22:36 +0100 Subject: [PATCH] feat: Display indicator for unread muted rooms --- lib/pages/chat/chat.dart | 2 +- lib/pages/chat_list/chat_list_item.dart | 17 ++++++++++------- lib/pages/chat_list/stories_header.dart | 4 ++-- pubspec.lock | 2 +- pubspec.yaml | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 6cfe8ccd3..2d2ba3c06 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -224,7 +224,7 @@ class ChatController extends State { } filteredEvents = timeline!.getFilteredEvents(unfolded: unfolded); timeline!.requestKeys(); - if (room!.notificationCount > 0 && + if (room!.hasNewMessages && timeline != null && timeline!.events.isNotEmpty && Matrix.of(context).webHasFocus) { diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index eac9a04a1..16ab09121 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -150,7 +150,7 @@ class ChatListItem extends StatelessWidget { final ownMessage = room.lastEvent?.senderId == Matrix.of(context).client.userID; final unread = room.isUnread || room.membership == Membership.invite; - final unreadBubbleSize = unread + final unreadBubbleSize = unread || room.hasNewMessages ? room.notificationCount > 0 ? 20.0 : 14.0 @@ -291,15 +291,18 @@ class ChatListItem extends StatelessWidget { curve: Curves.bounceInOut, padding: const EdgeInsets.symmetric(horizontal: 7), height: unreadBubbleSize, - width: room.notificationCount == 0 && !unread - ? 0 - : (unreadBubbleSize - 9) * - room.notificationCount.toString().length + - 9, + width: + room.notificationCount == 0 && !unread && !room.hasNewMessages + ? 0 + : (unreadBubbleSize - 9) * + room.notificationCount.toString().length + + 9, decoration: BoxDecoration( color: room.highlightCount > 0 ? Colors.red - : Theme.of(context).primaryColor, + : room.notificationCount > 0 + ? Theme.of(context).primaryColor + : Theme.of(context).primaryColor.withAlpha(100), borderRadius: BorderRadius.circular(AppConfig.borderRadius), ), child: Center( diff --git a/lib/pages/chat_list/stories_header.dart b/lib/pages/chat_list/stories_header.dart index 7323f3155..581168473 100644 --- a/lib/pages/chat_list/stories_header.dart +++ b/lib/pages/chat_list/stories_header.dart @@ -132,8 +132,8 @@ class StoriesHeader extends StatelessWidget { size: 100, fontSize: 24, ), - unread: room.notificationCount > 0 || - room.membership == Membership.invite, + unread: room.membership == Membership.invite || + room.hasNewMessages, onPressed: () => _goToStoryAction(context, room.id), onLongPressed: () => _contextualActions(context, room), ), diff --git a/pubspec.lock b/pubspec.lock index dd50a7603..72587639b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -832,7 +832,7 @@ packages: name: matrix url: "https://pub.dartlang.org" source: hosted - version: "0.8.5" + version: "0.8.6" matrix_api_lite: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a3cba7808..33e4669d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,7 +51,7 @@ dependencies: intl: any localstorage: ^4.0.0+1 lottie: ^1.2.1 - matrix: ^0.8.5 + matrix: ^0.8.6 matrix_link_text: ^1.0.2 open_noti_settings: ^0.4.0 package_info_plus: ^1.2.1 @@ -119,4 +119,4 @@ dependency_overrides: hosted: name: geolocator_android url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss - provider: 5.0.0 \ No newline at end of file + provider: 5.0.0