Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Aug 2, 2024
1 parent 773ec5a commit ae403f6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 44 deletions.
46 changes: 25 additions & 21 deletions Telegram/Common/MessageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,44 @@ public OpenUrlSourceChat(long chatId)

public class TonSite
{
public static bool TryCreate(Uri uri, out string magic)
public static bool TryCreate(IClientService clientService, Uri uri, out string magic)
{
magic = null;

if (string.Equals(uri.Scheme, "tonsite", StringComparison.OrdinalIgnoreCase) || uri.Host.EndsWith(".ton", StringComparison.OrdinalIgnoreCase))
{
var domain = clientService.Config.GetNamedString("ton_proxy_address", "magic.org");

magic = uri.Host
.Replace("-", "-h")
.Replace(".", "-d");
magic = $"https://{magic}.magic.org" + uri.PathAndQuery + uri.Fragment;
magic = $"https://{magic}.{domain}" + uri.PathAndQuery + uri.Fragment;
return true;
}

return false;
}

public static bool TryUnmask(string url, out Uri magic)
public static bool TryUnmask(IClientService clientService, string url, out Uri magic)
{
if (MessageHelper.TryCreateUri(url, out Uri navigation))
{
magic = Unmask(navigation);
magic = Unmask(clientService, navigation);
return true;
}

magic = null;
return false;
}

public static Uri Unmask(Uri navigation)
public static Uri Unmask(IClientService clientService, Uri navigation)
{
var domain = clientService.Config.GetNamedString("ton_proxy_address", "magic.org");

var host = navigation.Host;
if (host.EndsWith(".magic.org"))
if (host.EndsWith("." + domain))
{
host = host.Replace(".magic.org", string.Empty)
host = host.Replace("." + domain, string.Empty)
.Replace("-d", ".")
.Replace("-h", "-");
}
Expand Down Expand Up @@ -820,16 +824,16 @@ public static async void NavigateToMainWebApp(IClientService clientService, INav
menuBot = await clientService.SendAsync(new GetAttachmentMenuBot(botUser.Id)) as AttachmentMenuBot;
}

var popup = new MessagePopup
{
Title = Strings.AppName,
Message = Strings.BotWebViewStartPermission,
PrimaryButtonText = Strings.Start,
SecondaryButtonText = Strings.Cancel,
};

if (menuBot?.RequestWriteAccess is true)
{
var popup = new MessagePopup
{
Title = Strings.AppName,
Message = Strings.BotWebViewStartPermission,
PrimaryButtonText = Strings.Start,
SecondaryButtonText = Strings.Cancel,
};

var textBlock = new TextBlock
{
TextWrapping = TextWrapping.Wrap
Expand All @@ -846,12 +850,12 @@ public static async void NavigateToMainWebApp(IClientService clientService, INav
}

popup.CheckBoxLabel = textBlock;
}

var confirm = await popup.ShowQueuedAsync();
if (confirm != ContentDialogResult.Primary)
{
return;
var confirm = await popup.ShowQueuedAsync();
if (confirm != ContentDialogResult.Primary)
{
return;
}
}

var chatId = source switch
Expand Down Expand Up @@ -1402,7 +1406,7 @@ public static async void OpenUrl(IClientService clientService, INavigationServic
{
OpenTelegramUrl(clientService, navigationService, uri, source);
}
else if (navigationService != null && TonSite.TryCreate(uri, out string magic))
else if (clientService != null && navigationService != null && TonSite.TryCreate(clientService, uri, out string magic))
{
if (navigationService is TLNavigationService tl)
{
Expand Down
34 changes: 17 additions & 17 deletions Telegram/Common/WatchDog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ public static void Initialize()
args.SetObserved();
};

Crashes.UnhandledErrorDetected = () =>
{
try
{
var error = ToException(NativeUtils.GetFatalError(false));
if (error != null)
{
Crashes.TrackCrash(error);
}
return null;
}
catch
{
return null;
}
};
//Crashes.UnhandledErrorDetected = () =>
//{
// try
// {
// var error = ToException(NativeUtils.GetFatalError(false));
// if (error != null)
// {
// Crashes.TrackCrash(error);
// }

// return null;
// }
// catch
// {
// return null;
// }
//};

Crashes.CreatingErrorReport += (s, args) =>
{
Expand Down
12 changes: 7 additions & 5 deletions Telegram/Telegram.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@
<Content Include="Assets\Toasts\Error.tgs" />
<Content Include="Assets\Toasts\Archived.tgs" />
<Content Include="Assets\Toasts\Premium.tgs" />
<Content Include="Assets\Toasts\Gif.tgs" />
<None Include="Assets\Toasts\Pin.tgs" />
<None Include="Assets\Toasts\Unpin.tgs" />
<None Include="Telegram_StoreKey.pfx" />
Expand Down Expand Up @@ -3560,7 +3561,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.8.2</Version>
<Version>2.8.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.Web.WebView2">
<Version>1.0.2592.51</Version>
Expand All @@ -3569,7 +3570,7 @@
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="PolySharp">
<Version>1.13.2</Version>
<Version>1.14.1</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -3592,14 +3593,14 @@
<Version>3.3.7</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.26.0</Version>
<Version>1.27.1</Version>
</PackageReference>
<!-- Used by AppCenter -->
<PackageReference Include="SQLitePCLRaw.bundle_winsqlite3">
<Version>2.1.5</Version>
<Version>2.1.8</Version>
</PackageReference>
<PackageReference Include="System.Reflection.Metadata">
<Version>1.7.0</Version>
<Version>8.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -3638,6 +3639,7 @@
<ReferenceCopyLocalPaths Include="$(ProjectDir)\..\Libraries\rlottie\$(Platform)\RLottie.pri" />
<!--<ReferenceCopyLocalPaths Condition=" '$(Configuration)' == 'Debug' " Include="$(ProjectDir)\..\Libraries\rlottie\$(Platform)\zlib1.dll" />-->
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Telegram/Views/ChatView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,7 @@ private bool MessageSelect_Loaded(MessageViewModel message)

private bool MessageStatistics_Loaded(MessageViewModel message, MessageProperties properties)
{
return properties.CanGetStatistics;
return properties.NeedShowStatistics;
}

private bool MessageAddSticker_Loaded(MessageViewModel message)
Expand Down
3 changes: 3 additions & 0 deletions Telegram/Views/Tabbed/WebBrowserPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ private void OnInitialized(WebView2 sender, CoreWebView2InitializedEventArgs arg
_ => CoreWebView2PreferredColorScheme.Auto
};

sender.CoreWebView2.Settings.IsStatusBarEnabled = false;
sender.CoreWebView2.Settings.AreDevToolsEnabled = SettingsService.Current.Diagnostics.EnableWebViewDevTools;

sender.CoreWebView2.Navigate(_startUrl);
sender.CoreWebView2.SourceChanged += OnSourceChanged;
sender.CoreWebView2.HistoryChanged += OnHistoryChanged;
Expand Down

0 comments on commit ae403f6

Please sign in to comment.