Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions commet/lib/config/preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 6 additions & 4 deletions commet/lib/ui/pages/main/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,13 @@ class MainPageState extends State<MainPage> {
}

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);
Expand Down
21 changes: 20 additions & 1 deletion commet/lib/ui/pages/main/main_page_view_mobile.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -90,6 +91,22 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
return;
}

if (widget.state.currentView == MainPageSubView.home &&
widget.state.currentRoom != null) {
if (widget.state.currentRoom != null) {
var dm = widget.state.currentRoom!.client
.getComponent<DirectMessagesComponent>();
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);
Expand All @@ -102,7 +119,9 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
child: Foundation(
child: OverlappingPanels(
key: panelsKey,
onDragStart: () {},
onDragStart: () {
FocusManager.instance.primaryFocus?.unfocus();
},
onSideChange: (side) {
setState(() {
shouldMainIgnoreInput = side != RevealSide.main;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _BooleanPreferenceToggleState extends State<BooleanPreferenceToggle> {
),
),
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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ class GeneralSettingsPageState extends State<GeneralSettingsPage> {
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",
)
]),
),
Expand Down