refactor: Migrate from pathsegment routing

This commit is contained in:
Krille 2023-08-13 16:07:15 +02:00
commit b715eff839
No known key found for this signature in database
15 changed files with 20 additions and 23 deletions

View file

@ -218,7 +218,7 @@ class ChatController extends State<ChatPageWithRoom> {
); );
final roomId = success.result; final roomId = success.result;
if (roomId == null) return; if (roomId == null) return;
context.go(['', 'rooms', roomId].join('/')); context.go('/rooms/$roomId');
} }
void leaveChat() async { void leaveChat() async {
@ -1055,7 +1055,7 @@ class ChatController extends State<ChatPageWithRoom> {
future: room.leave, future: room.leave,
); );
if (result.error == null) { if (result.error == null) {
context.go(['', 'rooms', result.result!].join('/')); context.go('/rooms/${result.result!}');
} }
} }

View file

@ -23,7 +23,7 @@ class ChatAppBarTitle extends StatelessWidget {
highlightColor: Colors.transparent, highlightColor: Colors.transparent,
onTap: controller.isArchived onTap: controller.isArchived
? null ? null
: () => context.go(['', 'rooms', room.id, 'details'].join('/')), : () => context.go('/rooms/${room.id}/details'),
child: Row( child: Row(
children: [ children: [
Hero( Hero(

View file

@ -38,8 +38,7 @@ class EncryptionButton extends StatelessWidget {
? Colors.orange ? Colors.orange
: null, : null,
), ),
onPressed: () => onPressed: () => context.go('/rooms/${room.id}/encryption'),
context.go(['', 'rooms', room.id, 'encryption'].join('/')),
), ),
); );
}, },

View file

@ -28,8 +28,7 @@ class ChatEncryptionSettingsView extends StatelessWidget {
appBar: AppBar( appBar: AppBar(
leading: IconButton( leading: IconButton(
icon: const Icon(Icons.close_outlined), icon: const Icon(Icons.close_outlined),
onPressed: () => onPressed: () => context.go('/rooms/${controller.roomId!}'),
context.go(['', 'rooms', controller.roomId!].join('/')),
), ),
title: Text(L10n.of(context)!.encryption), title: Text(L10n.of(context)!.encryption),
actions: [ actions: [

View file

@ -61,7 +61,7 @@ class ChatListItem extends StatelessWidget {
} }
if (room.membership == Membership.leave) { if (room.membership == Membership.leave) {
context.go(['', 'archive', room.id].join('/')); context.go('/rooms/archive/${room.id}');
} }
if (room.membership == Membership.join) { if (room.membership == Membership.join) {
@ -86,7 +86,7 @@ class ChatListItem extends StatelessWidget {
Matrix.of(context).shareContent = null; Matrix.of(context).shareContent = null;
} }
context.go(['', 'rooms', room.id].join('/')); context.go('/rooms/${room.id}');
} }
} }

View file

@ -79,7 +79,7 @@ class _SpaceViewState extends State<SpaceView> {
} }
return; return;
} }
context.go(['', 'rooms', spaceChild.roomId].join('/')); context.go('/rooms/${spaceChild.roomId}');
} }
void _onSpaceChildContextMenu([ void _onSpaceChildContextMenu([

View file

@ -35,7 +35,7 @@ class StoriesHeader extends StatelessWidget {
); );
if (result.error != null) return; if (result.error != null) return;
} }
context.go(['', 'stories', roomId].join('/')); context.go('/stories/$roomId');
} }
void _contextualActions(BuildContext context, Room room) async { void _contextualActions(BuildContext context, Room room) async {

View file

@ -37,7 +37,7 @@ class NewGroupController extends State<NewGroup> {
}, },
); );
if (roomID.error == null) { if (roomID.error == null) {
context.go(['', 'rooms', roomID.result!, 'invite'].join('/')); context.go('/rooms/${roomID.result!}/invite');
} }
} }

View file

@ -497,7 +497,7 @@ class StoryPageController extends State<StoryPage> {
currentEvent!.senderFromMemoryOrFallback.startDirectChat(), currentEvent!.senderFromMemoryOrFallback.startDirectChat(),
); );
if (roomIdResult.error != null) return; if (roomIdResult.error != null) return;
context.go(['', 'rooms', roomIdResult.result!].join('/')); context.go('/rooms/${roomIdResult.result!}');
break; break;
} }

View file

@ -208,7 +208,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
.startDirectChat(user?.id ?? widget.profile!.userId), .startDirectChat(user?.id ?? widget.profile!.userId),
); );
if (roomIdResult.error != null) return; if (roomIdResult.error != null) return;
widget.outerContext.go(['', 'rooms', roomIdResult.result!].join('/')); widget.outerContext.go('/rooms/${roomIdResult.result!}');
Navigator.of(context, rootNavigator: false).pop(); Navigator.of(context, rootNavigator: false).pop();
break; break;
case UserBottomSheetAction.ignore: case UserBottomSheetAction.ignore:

View file

@ -312,8 +312,7 @@ class BackgroundPush {
?.content ?.content
.tryGet<String>('type') == .tryGet<String>('type') ==
ClientStoriesExtension.storiesRoomType; ClientStoriesExtension.storiesRoomType;
FluffyChatApp.router FluffyChatApp.router.go('/${isStory ? 'stories' : 'rooms'}/$roomId');
.go(['', isStory ? 'stories' : 'rooms', roomId].join('/'));
} catch (e, s) { } catch (e, s) {
Logs().e('[Push] Failed to open room', e, s); Logs().e('[Push] Failed to open room', e, s);
} }

View file

@ -172,7 +172,7 @@ class UrlLauncher {
if (room != null) { if (room != null) {
if (room.isSpace) { if (room.isSpace) {
// TODO: Implement navigate to space // TODO: Implement navigate to space
context.go(['', 'rooms'].join('/')); context.go('/rooms/${room.id}');
return; return;
} }
@ -185,7 +185,7 @@ class UrlLauncher {
).toString(), ).toString(),
); );
} else { } else {
context.go(['', 'rooms', room.id].join('/')); context.go('/rooms/${room.id}');
} }
return; return;
} else { } else {
@ -226,7 +226,7 @@ class UrlLauncher {
).toString(), ).toString(),
); );
} else { } else {
context.go(['', 'rooms', response.result!].join('/')); context.go('/rooms/${response.result!}');
} }
} }
} }

View file

@ -196,9 +196,9 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
void _showChatDetails() { void _showChatDetails() {
if (GoRouterState.of(context).uri.path.endsWith('/details')) { if (GoRouterState.of(context).uri.path.endsWith('/details')) {
context.go(['', 'rooms', widget.room.id].join('/')); context.go('/rooms/${widget.room.id}');
} else { } else {
context.go(['', 'rooms', widget.room.id, 'details'].join('/')); context.go('/rooms/${widget.room.id}/details');
} }
} }
} }

View file

@ -113,7 +113,7 @@ extension LocalNotificationsExtension on MatrixState {
room.setReadMarker(event.eventId, mRead: event.eventId); room.setReadMarker(event.eventId, mRead: event.eventId);
break; break;
case DesktopNotificationActions.openChat: case DesktopNotificationActions.openChat:
context.go(['', 'rooms', room.id].join('/')); context.go('/rooms/${room.id}');
break; break;
} }
}); });

View file

@ -53,7 +53,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
navigator.pop(); navigator.pop();
// don't open the room if the joined room is a space // don't open the room if the joined room is a space
if (!client.getRoomById(result.result!)!.isSpace) { if (!client.getRoomById(result.result!)!.isSpace) {
context.go(['', 'rooms', result.result!].join('/')); context.go('/rooms/${result.result!}');
} }
return; return;
} }