From 0760acaa40a4e30d85f8c0eed35c6df7a7e7e660 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Mon, 22 Jul 2024 19:42:27 +0200 Subject: [PATCH] chore: Bring back separate chat types --- lib/config/app_config.dart | 1 + lib/config/setting_keys.dart | 1 + lib/pages/chat_list/chat_list.dart | 7 ++++++- lib/pages/chat_list/chat_list_body.dart | 7 +++++-- lib/pages/settings_style/settings_style_view.dart | 6 ++++++ lib/widgets/matrix.dart | 4 ++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 6ee20d337..841d810ec 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -44,6 +44,7 @@ abstract class AppConfig { static bool hideRedactedEvents = false; static bool hideUnknownEvents = true; static bool hideUnimportantStateEvents = true; + static bool separateChatTypes = false; static bool autoplayImages = true; static bool sendTypingNotifications = true; static bool sendPublicReadReceipts = true; diff --git a/lib/config/setting_keys.dart b/lib/config/setting_keys.dart index 5b795b08e..7c0e50df8 100644 --- a/lib/config/setting_keys.dart +++ b/lib/config/setting_keys.dart @@ -4,6 +4,7 @@ abstract class SettingKeys { static const String hideUnknownEvents = 'chat.fluffy.hideUnknownEvents'; static const String hideUnimportantStateEvents = 'chat.fluffy.hideUnimportantStateEvents'; + static const String separateChatTypes = 'chat.fluffy.separateChatTypes'; static const String sentry = 'sentry'; static const String theme = 'theme'; static const String amoledEnabled = 'amoled_enabled'; diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 50237a569..13ce54053 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -50,8 +50,9 @@ enum PopupMenuAction { enum ActiveFilter { allChats, - unread, + messages, groups, + unread, spaces, } @@ -60,6 +61,8 @@ extension LocalizedActiveFilter on ActiveFilter { switch (this) { case ActiveFilter.allChats: return L10n.of(context)!.all; + case ActiveFilter.messages: + return L10n.of(context)!.messages; case ActiveFilter.unread: return L10n.of(context)!.unread; case ActiveFilter.groups: @@ -321,6 +324,8 @@ class ChatListController extends State switch (activeFilter) { case ActiveFilter.allChats: return (room) => true; + case ActiveFilter.messages: + return (room) => !room.isSpace && room.isDirectChat; case ActiveFilter.groups: return (room) => !room.isSpace && !room.isDirectChat; case ActiveFilter.unread: diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index e596440b3..d78a88e34 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -165,9 +165,12 @@ class ChatListViewBody extends StatelessWidget { shrinkWrap: true, scrollDirection: Axis.horizontal, children: [ - ActiveFilter.allChats, - ActiveFilter.unread, + if (AppConfig.separateChatTypes) + ActiveFilter.messages + else + ActiveFilter.allChats, ActiveFilter.groups, + ActiveFilter.unread, if (spaceDelegateCandidates.isNotEmpty && !controller.widget.displayNavigationRail) ActiveFilter.spaces, diff --git a/lib/pages/settings_style/settings_style_view.dart b/lib/pages/settings_style/settings_style_view.dart index 0b505d597..86f48fe87 100644 --- a/lib/pages/settings_style/settings_style_view.dart +++ b/lib/pages/settings_style/settings_style_view.dart @@ -185,6 +185,12 @@ class SettingsStyleView extends StatelessWidget { storeKey: SettingKeys.showPresences, defaultValue: AppConfig.showPresences, ), + SettingsSwitchListTile.adaptive( + title: L10n.of(context)!.separateChatTypes, + onChanged: (b) => AppConfig.separateChatTypes = b, + storeKey: SettingKeys.separateChatTypes, + defaultValue: AppConfig.separateChatTypes, + ), Divider( height: 1, color: Theme.of(context).dividerColor, diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 581e3ccff..4de23a2f5 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -433,6 +433,10 @@ class MatrixState extends State with WidgetsBindingObserver { store.getBool(SettingKeys.hideUnimportantStateEvents) ?? AppConfig.hideUnimportantStateEvents; + AppConfig.separateChatTypes = + store.getBool(SettingKeys.separateChatTypes) ?? + AppConfig.separateChatTypes; + AppConfig.autoplayImages = store.getBool(SettingKeys.autoplayImages) ?? AppConfig.autoplayImages;