Skip to content

Commit

Permalink
JavaScript was disabled (#271)
Browse files Browse the repository at this point in the history
* JavaScript was disabled

* function was renamed
  • Loading branch information
ValeraFinebits authored Jun 25, 2024
1 parent 197836f commit e0d2ce3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
private static void OnStringSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
public static readonly DependencyProperty StringSourceWithDisabledJavaScriptProperty =
DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourceWithDisabledJavaScriptPropertyChanged));
private static void OnStringSourceWithDisabledJavaScriptPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is WebView webView)
{
webView.Settings.IsJavaScriptEnabled = false;

webView.NavigateToString(e.NewValue as string ?? "");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
BorderBrush="#FFE0E0E0"
BorderThickness="1">

<WebView extensions:WebViewExtension.StringSource="{x:Bind ViewModel.MessageInfo.MessageHtmlBody, Mode=OneWay}"
<WebView extensions:WebViewExtension.StringSourceWithDisabledJavaScript="{x:Bind ViewModel.MessageInfo.MessageHtmlBody, Mode=OneWay}"
Visibility="{x:Bind ViewModel.MessageInfo.HasHtmlBody, Mode=OneWay}" />

<ScrollViewer Padding="4"
Expand Down

0 comments on commit e0d2ce3

Please sign in to comment.