From 54d0623b5f634863e945b3816d4a2561eed8c535 Mon Sep 17 00:00:00 2001 From: Valera Date: Tue, 25 Jun 2024 12:41:01 +0300 Subject: [PATCH 1/2] JavaScript was disabled --- .../Extensions/WebViewExtension.cs | 14 ++++++++------ .../Eppie.App.Shared/Views/MessagePage.xaml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs b/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs index 280b9d92..2740f35d 100644 --- a/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs +++ b/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs @@ -5,22 +5,24 @@ namespace Tuvi.App.Shared.Extensions { public static class WebViewExtension { - public static string GetStringSource(DependencyObject obj) + public static string GetStringSourceWithDisabledJavaScript(DependencyObject obj) { - return (string)obj?.GetValue(StringSourceProperty); + return (string)obj?.GetValue(StringSourceWithDisabledJavaScriptProperty); } - public static void SetStringSource(DependencyObject obj, string value) + public static void SetStringSourceWithDisabledJavaScript(DependencyObject obj, string value) { - obj?.SetValue(StringSourceProperty, value); + obj?.SetValue(StringSourceWithDisabledJavaScriptProperty, value); } - public static readonly DependencyProperty StringSourceProperty = - DependencyProperty.RegisterAttached("StringSource", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourcePropertyChanged)); + public static readonly DependencyProperty StringSourceWithDisabledJavaScriptProperty = + DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourcePropertyChanged)); private static void OnStringSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is WebView webView) { + webView.Settings.IsJavaScriptEnabled = false; + webView.NavigateToString(e.NewValue as string ?? ""); } } diff --git a/src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml b/src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml index 9365b58d..da01b4cb 100644 --- a/src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml +++ b/src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml @@ -233,7 +233,7 @@ BorderBrush="#FFE0E0E0" BorderThickness="1"> - Date: Tue, 25 Jun 2024 12:45:48 +0300 Subject: [PATCH 2/2] function was renamed --- src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs b/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs index 2740f35d..145e8df4 100644 --- a/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs +++ b/src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs @@ -16,8 +16,8 @@ public static void SetStringSourceWithDisabledJavaScript(DependencyObject obj, s } public static readonly DependencyProperty StringSourceWithDisabledJavaScriptProperty = - DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourcePropertyChanged)); - private static void OnStringSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourceWithDisabledJavaScriptPropertyChanged)); + private static void OnStringSourceWithDisabledJavaScriptPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is WebView webView) {