[OOBE] Fix release notes error InfoBars (#37804)

* fix infobars not visible
* minor changes and retry button when there is error to loading the release note page
This commit is contained in:
Davide Giacometti 2025-03-19 01:12:29 +01:00 committed by GitHub
parent f6b53d1088
commit 648c3eb0bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 57 additions and 15 deletions

View File

@ -14,6 +14,7 @@
<Grid Margin="0,24,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
@ -84,20 +85,42 @@
Grid.Row="2"
VerticalAlignment="Top"
IsClosable="False"
IsOpen="False"
IsTabStop="True"
Severity="Error" />
IsTabStop="False"
Severity="Error">
<InfoBar.ActionButton>
<Button
x:Uid="RetryBtn"
HorizontalAlignment="Right"
Click="LoadReleaseNotes_Click">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon FontSize="16" Glyph="&#xE72C;" />
<TextBlock x:Uid="RetryLabel" />
</StackPanel>
</Button>
</InfoBar.ActionButton>
</InfoBar>
<InfoBar
x:Name="ProxyWarningInfoBar"
x:Uid="Oobe_WhatsNew_ProxyAuthenticationWarning"
Grid.Row="2"
VerticalAlignment="Top"
IsClosable="False"
IsOpen="False"
IsTabStop="True"
Severity="Warning" />
IsTabStop="False"
Severity="Warning">
<InfoBar.ActionButton>
<Button
x:Uid="RetryBtn"
HorizontalAlignment="Right"
Click="LoadReleaseNotes_Click">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon FontSize="16" Glyph="&#xE72C;" />
<TextBlock x:Uid="RetryLabel" />
</StackPanel>
</Button>
</InfoBar.ActionButton>
</InfoBar>
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto">
<ScrollViewer Grid.Row="3" VerticalScrollBarVisibility="Auto">
<Grid Margin="32,24,32,24">
<ProgressRing
x:Name="LoadingProgressRing"

View File

@ -10,7 +10,6 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -77,6 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private const string RemoveInstallerHashesRegex = @"(\r\n)+## Installer Hashes(\r\n.*)+## Highlights";
private const string RemoveHotFixInstallerHashesRegex = @"(\r\n)+## Installer Hashes(\r\n.*)+$";
private const RegexOptions RemoveInstallerHashesRegexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
private bool _loadingReleaseNotes;
private static async Task<string> GetReleaseNotesMarkdown()
{
@ -127,12 +127,19 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private async Task Reload()
{
if (_loadingReleaseNotes)
{
return;
}
try
{
_loadingReleaseNotes = true;
ReleaseNotesMarkdown.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
LoadingProgressRing.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
string releaseNotesMarkdown = await GetReleaseNotesMarkdown();
ProxyWarningInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
ProxyWarningInfoBar.IsOpen = false;
ErrorInfoBar.IsOpen = false;
ReleaseNotesMarkdown.Text = releaseNotesMarkdown;
ReleaseNotesMarkdown.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
@ -143,21 +150,22 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
Logger.LogError("Exception when loading the release notes", httpEx);
if (httpEx.Message.Contains("407", StringComparison.CurrentCulture))
{
ProxyWarningInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
ProxyWarningInfoBar.IsOpen = true;
}
else
{
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
ErrorInfoBar.IsOpen = true;
}
}
catch (Exception ex)
{
Logger.LogError("Exception when loading the release notes", ex);
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
ErrorInfoBar.IsOpen = true;
}
finally
{
LoadingProgressRing.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
_loadingReleaseNotes = false;
}
}
@ -248,5 +256,10 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
Common.UI.SettingsDeepLink.OpenSettings(Common.UI.SettingsDeepLink.SettingsWindow.Overview, true);
}
private async void LoadReleaseNotes_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
await Reload();
}
}
}

View File

@ -4941,6 +4941,12 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
</data>
<data name="SettingsPage_NewInfoBadge.Text" xml:space="preserve">
<value>NEW</value>
<comment>Must be all caps</comment>
<comment>Must be all caps</comment>
</data>
<data name="RetryBtn.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Retry</value>
</data>
<data name="RetryLabel.Text" xml:space="preserve">
<value>Retry</value>
</data>
</root>