Skip to content

Commit

Permalink
fix: disable redirect in embed (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Nov 20, 2024
1 parent d720a18 commit fb5038c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/view/widget/player_embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ class PlayerEmbed extends ConsumerWidget {
),
initialUrlRequest: URLRequest(url: WebUri.uri(replacedUrl)),
shouldOverrideUrlLoading: (controller, navigationAction) async {
final url = navigationAction.request.url;
if (navigationAction.hasGesture ?? false) {
final url = navigationAction.request.url;
if (url != null) {
await launchUrl(ref, url);
return NavigationActionPolicy.CANCEL;
}
}
return NavigationActionPolicy.ALLOW;
if (url?.normalizePath() == replacedUrl.normalizePath()) {
return NavigationActionPolicy.ALLOW;
} else {
return NavigationActionPolicy.CANCEL;
}
},
);

Expand Down
4 changes: 1 addition & 3 deletions lib/view/widget/twitter_embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ class TwitterEmbed extends HookConsumerWidget {
height: height.value,
child: InAppWebView(
initialSettings: InAppWebViewSettings(transparentBackground: true),
initialUrlRequest: URLRequest(
url: WebUri.uri(Uri.dataFromString(content, mimeType: 'text/html')),
),
initialData: InAppWebViewInitialData(data: content),
onWebViewCreated: (controller) => controller.addJavaScriptHandler(
handlerName: 'onReady',
callback: (arguments) =>
Expand Down

0 comments on commit fb5038c

Please sign in to comment.