diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 331f3f1a..d6de4aa2 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -82,45 +82,51 @@ class FluffyRoutes { emptyView: (_) => EmptyPage(), ); case 'rooms': + final roomId = parts[2]; if (parts.length == 3) { return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), ); } else if (parts.length == 4) { - final roomId = parts[2]; final action = parts[3]; switch (action) { case 'details': return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), rightView: (_) => ChatDetails(roomId), ); case 'encryption': return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), rightView: (_) => ChatEncryptionSettings(roomId), ); case 'permissions': return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), rightView: (_) => ChatPermissionsSettings(roomId), ); case 'invite': return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), rightView: (_) => InvitationSelection(roomId), ); case 'emotes': return ViewData( - leftView: (_) => ChatList(activeChat: parts[2]), - mainView: (_) => Chat(parts[2]), + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId), rightView: (_) => MultipleEmotesSettings(roomId), ); + default: + return ViewData( + leftView: (_) => ChatList(activeChat: roomId), + mainView: (_) => Chat(roomId, + scrollToEventId: action.sigil == '\$' ? action : null), + ); } } return ViewData( diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index e00e5f09..121b5da6 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -71,9 +71,14 @@ class UrlLauncher { } } if (room != null) { - // we have the room, so....just open it! - await AdaptivePageLayout.of(context) - .pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}/$event'); + // we have the room, so....just open it + if (event != null) { + await AdaptivePageLayout.of(context) + .pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}/$event'); + } else { + await AdaptivePageLayout.of(context) + .pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}'); + } return; } if (roomIdOrAlias.sigil == '!') { @@ -95,8 +100,13 @@ class UrlLauncher { await showFutureLoadingDialog( context: context, future: () => Future.delayed(const Duration(seconds: 2))); - await AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst( - '/rooms/${response.result}/$event'); + if (event != null) { + await AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst( + '/rooms/${response.result}/$event'); + } else { + await AdaptivePageLayout.of(context) + .pushNamedAndRemoveUntilIsFirst('/rooms/${response.result}'); + } } } else { await AdaptivePageLayout.of(context)