fix: Make tap on pills and matrix.to links work again

This commit is contained in:
Sorunome 2021-01-19 17:41:37 +01:00
parent 2c3c0dbdb2
commit 48ad322857
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 34 additions and 18 deletions

View File

@ -82,45 +82,51 @@ class FluffyRoutes {
emptyView: (_) => EmptyPage(), emptyView: (_) => EmptyPage(),
); );
case 'rooms': case 'rooms':
final roomId = parts[2];
if (parts.length == 3) { if (parts.length == 3) {
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
); );
} else if (parts.length == 4) { } else if (parts.length == 4) {
final roomId = parts[2];
final action = parts[3]; final action = parts[3];
switch (action) { switch (action) {
case 'details': case 'details':
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
rightView: (_) => ChatDetails(roomId), rightView: (_) => ChatDetails(roomId),
); );
case 'encryption': case 'encryption':
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
rightView: (_) => ChatEncryptionSettings(roomId), rightView: (_) => ChatEncryptionSettings(roomId),
); );
case 'permissions': case 'permissions':
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
rightView: (_) => ChatPermissionsSettings(roomId), rightView: (_) => ChatPermissionsSettings(roomId),
); );
case 'invite': case 'invite':
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
rightView: (_) => InvitationSelection(roomId), rightView: (_) => InvitationSelection(roomId),
); );
case 'emotes': case 'emotes':
return ViewData( return ViewData(
leftView: (_) => ChatList(activeChat: parts[2]), leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(roomId),
rightView: (_) => MultipleEmotesSettings(roomId), rightView: (_) => MultipleEmotesSettings(roomId),
); );
default:
return ViewData(
leftView: (_) => ChatList(activeChat: roomId),
mainView: (_) => Chat(roomId,
scrollToEventId: action.sigil == '\$' ? action : null),
);
} }
} }
return ViewData( return ViewData(

View File

@ -71,9 +71,14 @@ class UrlLauncher {
} }
} }
if (room != null) { if (room != null) {
// we have the room, so....just open it! // we have the room, so....just open it
await AdaptivePageLayout.of(context) if (event != null) {
.pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}/$event'); await AdaptivePageLayout.of(context)
.pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}/$event');
} else {
await AdaptivePageLayout.of(context)
.pushNamedAndRemoveUntilIsFirst('/rooms/${room.id}');
}
return; return;
} }
if (roomIdOrAlias.sigil == '!') { if (roomIdOrAlias.sigil == '!') {
@ -95,8 +100,13 @@ class UrlLauncher {
await showFutureLoadingDialog( await showFutureLoadingDialog(
context: context, context: context,
future: () => Future.delayed(const Duration(seconds: 2))); future: () => Future.delayed(const Duration(seconds: 2)));
await AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst( if (event != null) {
'/rooms/${response.result}/$event'); await AdaptivePageLayout.of(context).pushNamedAndRemoveUntilIsFirst(
'/rooms/${response.result}/$event');
} else {
await AdaptivePageLayout.of(context)
.pushNamedAndRemoveUntilIsFirst('/rooms/${response.result}');
}
} }
} else { } else {
await AdaptivePageLayout.of(context) await AdaptivePageLayout.of(context)