diff --git a/commet/lib/config/preferences.dart b/commet/lib/config/preferences.dart index 66d35b771..ced30c1c3 100644 --- a/commet/lib/config/preferences.dart +++ b/commet/lib/config/preferences.dart @@ -306,6 +306,9 @@ class Preferences { defaultGetter: () => Layout.mobile ? false : true, defaultValue: false); + BoolPreference automaticallyOpenSpace = + BoolPreference("open_space_on_room_navigation", defaultValue: true); + BoolPreference autoRotateImages = BoolPreference("lightbox_rotate_images", defaultValue: false); diff --git a/commet/lib/ui/pages/main/main_page.dart b/commet/lib/ui/pages/main/main_page.dart index 466683994..56b6acd01 100644 --- a/commet/lib/ui/pages/main/main_page.dart +++ b/commet/lib/ui/pages/main/main_page.dart @@ -320,11 +320,13 @@ class MainPageState extends State { } if (room != null) { - var spacesWithRoom = - client.spaces.where((element) => element.containsRoom(roomId)); + if (preferences.automaticallyOpenSpace.value) { + var spacesWithRoom = + client.spaces.where((element) => element.containsRoom(roomId)); - if (spacesWithRoom.isNotEmpty) { - selectSpace(spacesWithRoom.first); + if (spacesWithRoom.isNotEmpty) { + selectSpace(spacesWithRoom.first); + } } selectRoom(room); diff --git a/commet/lib/ui/pages/main/main_page_view_mobile.dart b/commet/lib/ui/pages/main/main_page_view_mobile.dart index f3923ea2b..1d793ee36 100644 --- a/commet/lib/ui/pages/main/main_page_view_mobile.dart +++ b/commet/lib/ui/pages/main/main_page_view_mobile.dart @@ -1,3 +1,4 @@ +import 'package:commet/client/components/direct_messages/direct_message_component.dart'; import 'package:commet/client/room.dart'; import 'package:commet/config/layout_config.dart'; import 'package:commet/ui/atoms/room_header.dart'; @@ -90,6 +91,22 @@ class _MainPageViewMobileState extends State { return; } + if (widget.state.currentView == MainPageSubView.home && + widget.state.currentRoom != null) { + if (widget.state.currentRoom != null) { + var dm = widget.state.currentRoom!.client + .getComponent(); + if (dm?.isRoomDirectMessage(widget.state.currentRoom!) == true) { + panelsKey.currentState?.reveal(RevealSide.left); + return; + } + } + + widget.state.selectHome(); + + return; + } + switch (panelsKey.currentState?.currentSide) { case RevealSide.right: panelsKey.currentState?.reveal(RevealSide.main); @@ -102,7 +119,9 @@ class _MainPageViewMobileState extends State { child: Foundation( child: OverlappingPanels( key: panelsKey, - onDragStart: () {}, + onDragStart: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, onSideChange: (side) { setState(() { shouldMainIgnoreInput = side != RevealSide.main; diff --git a/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart b/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart index de62efabd..f98d41878 100644 --- a/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart +++ b/commet/lib/ui/pages/settings/categories/app/boolean_toggle.dart @@ -45,7 +45,7 @@ class _BooleanPreferenceToggleState extends State { ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.fromLTRB(8, 8, 0, 8), child: tiamat.Switch( state: widget.preference.value, onChanged: (value) async { @@ -100,7 +100,7 @@ class _NullableBooleanPreferenceToggleState ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.fromLTRB(8, 8, 0, 8), child: tiamat.Switch( state: widget.preference.value ?? false, onChanged: (value) async { diff --git a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart index 969823041..70ab61193 100644 --- a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart +++ b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart @@ -152,6 +152,12 @@ class GeneralSettingsPageState extends State { title: "Autofocus Message Input", description: "Automatically focus on the message input text field when opening a chat", + ), + BooleanPreferenceToggle( + preference: preferences.automaticallyOpenSpace, + title: "Always open space", + description: + "When navigating to a room from outside of a space, also open the space the room is in, if any", ) ]), ),