Skip to content

Commit

Permalink
Merge pull request #242 from humhub/239-page-not-found-using-app
Browse files Browse the repository at this point in the history
Remove web support script, only load it on before iframe open.
  • Loading branch information
luke- authored Oct 12, 2024
2 parents fb8b88a + 9663da9 commit 4d22ca9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
3 changes: 0 additions & 3 deletions lib/pages/web_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class WebViewAppState extends ConsumerState<WebView> {
Future<NavigationActionPolicy?> _shouldOverrideUrlLoading(
InAppWebViewController controller, NavigationAction action) async {
WebViewGlobalController.ajaxSetHeaders(headers: ref.read(humHubProvider).customHeaders);
WebViewGlobalController.injectWebSupportScript();

final url = action.request.url!.rawValue;

Expand Down Expand Up @@ -218,13 +217,11 @@ class WebViewAppState extends ConsumerState<WebView> {
"document.querySelector('#account-login-form > div.form-group.field-login-rememberme').style.display='none';");
}
WebViewGlobalController.ajaxSetHeaders(headers: ref.read(humHubProvider).customHeaders);
WebViewGlobalController.injectWebSupportScript();
LoadingProvider.of(ref).dismissAll();
}

void _onLoadStart(InAppWebViewController controller, Uri? url) async {
WebViewGlobalController.ajaxSetHeaders(headers: ref.read(humHubProvider).customHeaders);
WebViewGlobalController.injectWebSupportScript();
}

_onProgressChanged(InAppWebViewController controller, int progress) {
Expand Down
13 changes: 0 additions & 13 deletions lib/util/web_view_global_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ class WebViewGlobalController {
value?.evaluateJavascript(source: jsCode);
}

static void injectWebSupportScript() {
String script = """
var head = document.head || document.getElementsByTagName('head')[0];
var scriptElement = document.createElement('script');
scriptElement.type = 'application/javascript';
scriptElement.src = '/assets/packages/flutter_inappwebview/assets/web/web_support.js';
scriptElement.defer = true;
head.appendChild(scriptElement);
""";

value?.evaluateJavascript(source: script);
}

static InAppWebViewSettings get settings => InAppWebViewSettings(
useShouldOverrideUrlLoading: true,
useShouldInterceptFetchRequest: true,
Expand Down

0 comments on commit 4d22ca9

Please sign in to comment.