diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 494b7573..e63c0cc3 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2145,6 +2145,11 @@ "type": "text", "placeholders": {} }, + "showDirectChatsInSpaces": "Show related Direct Chats in Spaces", + "@showDirectChatsInSpaces": { + "type": "text", + "placeholders": {} + }, "showPassword": "Show password", "@showPassword": { "type": "text", diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 5040b3dc..bb0b8b3f 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -36,6 +36,7 @@ abstract class AppConfig { static bool renderHtml = true; static bool hideRedactedEvents = false; static bool hideUnknownEvents = true; + static bool showDirectChatsInSpaces = true; static bool separateChatTypes = false; static bool autoplayImages = true; static bool sendOnEnter = false; diff --git a/lib/config/setting_keys.dart b/lib/config/setting_keys.dart index c629201c..94f4ab07 100644 --- a/lib/config/setting_keys.dart +++ b/lib/config/setting_keys.dart @@ -3,6 +3,8 @@ abstract class SettingKeys { static const String renderHtml = 'chat.fluffy.renderHtml'; static const String hideRedactedEvents = 'chat.fluffy.hideRedactedEvents'; static const String hideUnknownEvents = 'chat.fluffy.hideUnknownEvents'; + static const String showDirectChatsInSpaces = + 'chat.fluffy.showDirectChatsInSpaces'; static const String separateChatTypes = 'chat.fluffy.separateChatTypes'; static const String chatColor = 'chat.fluffy.chat_color'; static const String sentry = 'sentry'; diff --git a/lib/pages/chat_list/spaces_entry.dart b/lib/pages/chat_list/spaces_entry.dart index a203e3a3..1c1c6b2c 100644 --- a/lib/pages/chat_list/spaces_entry.dart +++ b/lib/pages/chat_list/spaces_entry.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_extension.dart'; import '../../widgets/matrix.dart'; @@ -162,7 +163,7 @@ class SpaceSpacesEntry extends SpacesEntry { if (_roomInsideSpace(room, space)) { return true; } - if (true) { + if (AppConfig.showDirectChatsInSpaces) { if (room.isDirectChat && room.summary.mHeroes != null && room.summary.mHeroes!.any((userId) { diff --git a/lib/pages/settings_chat/settings_chat_view.dart b/lib/pages/settings_chat/settings_chat_view.dart index 2b381c64..ed6ea93d 100644 --- a/lib/pages/settings_chat/settings_chat_view.dart +++ b/lib/pages/settings_chat/settings_chat_view.dart @@ -77,6 +77,12 @@ class SettingsChatView extends StatelessWidget { ), ), const Divider(height: 1), + SettingsSwitchListTile.adaptive( + title: L10n.of(context)!.showDirectChatsInSpaces, + onChanged: (b) => AppConfig.showDirectChatsInSpaces = b, + storeKey: SettingKeys.showDirectChatsInSpaces, + defaultValue: AppConfig.showDirectChatsInSpaces, + ), SettingsSwitchListTile.adaptive( title: L10n.of(context)!.separateChatTypes, onChanged: (b) => AppConfig.separateChatTypes = b, diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index f14a7e40..8bad307a 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -480,6 +480,10 @@ class MatrixState extends State with WidgetsBindingObserver { store .getItemBool(SettingKeys.hideUnknownEvents, AppConfig.hideUnknownEvents) .then((value) => AppConfig.hideUnknownEvents = value); + store + .getItemBool(SettingKeys.showDirectChatsInSpaces, + AppConfig.showDirectChatsInSpaces) + .then((value) => AppConfig.showDirectChatsInSpaces = value); store .getItemBool(SettingKeys.separateChatTypes, AppConfig.separateChatTypes) .then((value) => AppConfig.separateChatTypes = value);