Merge branch 'krille/fix-open-uris' into 'main'

fix: Open URIs

See merge request famedly/fluffychat!593
This commit is contained in:
Krille Fear 2021-11-29 15:41:53 +00:00
commit 745d94f46f
3 changed files with 17 additions and 12 deletions

View File

@ -130,9 +130,9 @@ class ChatListController extends State<ChatList> {
void _processIncomingUris(String text) async { void _processIncomingUris(String text) async {
if (text == null) return; if (text == null) return;
VRouter.of(context).to('/rooms'); VRouter.of(context).to('/rooms');
text = text.replaceFirst('im.fluffychat://', 'matrix:'); WidgetsBinding.instance.addPostFrameCallback((_) {
UrlLauncher(context, text).openMatrixToUrl(); UrlLauncher(context, text).openMatrixToUrl();
return; });
} }
void _initReceiveSharingIntent() { void _initReceiveSharingIntent() {

View File

@ -83,7 +83,7 @@ class NewPrivateChatView extends StatelessWidget {
decoration: InputDecoration( decoration: InputDecoration(
labelText: L10n.of(context).typeInInviteLinkManually, labelText: L10n.of(context).typeInInviteLinkManually,
hintText: '@username', hintText: '@username',
prefixText: 'https://matrix.to/#/', prefixText: 'matrix.to/#/',
suffixIcon: IconButton( suffixIcon: IconButton(
icon: const Icon(Icons.send_outlined), icon: const Icon(Icons.send_outlined),
onPressed: controller.submitAction, onPressed: controller.submitAction,

View File

@ -87,6 +87,11 @@ class UrlLauncher {
void openMatrixToUrl() async { void openMatrixToUrl() async {
final matrix = Matrix.of(context); final matrix = Matrix.of(context);
final url = this.url.replaceFirst(
AppConfig.deepLinkPrefix,
AppConfig.inviteLinkPrefix,
);
// The identifier might be a matrix.to url and needs escaping. Or, it might have multiple // The identifier might be a matrix.to url and needs escaping. Or, it might have multiple
// identifiers (room id & event id), or it might also have a query part. // identifiers (room id & event id), or it might also have a query part.
// All this needs parsing. // All this needs parsing.
@ -135,6 +140,14 @@ class UrlLauncher {
VRouter.of(context).toSegments(['rooms', room.id]); VRouter.of(context).toSegments(['rooms', room.id]);
} }
return; return;
} else {
await showModalBottomSheet(
context: context,
builder: (c) => PublicRoomBottomSheet(
roomAlias: identityParts.primaryIdentifier,
outerContext: context,
),
);
} }
if (roomIdOrAlias.sigil == '!') { if (roomIdOrAlias.sigil == '!') {
if (await showOkCancelAlertDialog( if (await showOkCancelAlertDialog(
@ -163,14 +176,6 @@ class UrlLauncher {
VRouter.of(context).toSegments(['rooms', response.result]); VRouter.of(context).toSegments(['rooms', response.result]);
} }
} }
} else {
await showModalBottomSheet(
context: context,
builder: (c) => PublicRoomBottomSheet(
roomAlias: identityParts.primaryIdentifier,
outerContext: context,
),
);
} }
} else if (identityParts.primaryIdentifier.sigil == '@') { } else if (identityParts.primaryIdentifier.sigil == '@') {
await showModalBottomSheet( await showModalBottomSheet(