[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 Margin="0,24,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -84,20 +85,42 @@
Grid.Row="2" Grid.Row="2"
VerticalAlignment="Top" VerticalAlignment="Top"
IsClosable="False" IsClosable="False"
IsOpen="False" IsTabStop="False"
IsTabStop="True" Severity="Error">
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 <InfoBar
x:Name="ProxyWarningInfoBar" x:Name="ProxyWarningInfoBar"
x:Uid="Oobe_WhatsNew_ProxyAuthenticationWarning" x:Uid="Oobe_WhatsNew_ProxyAuthenticationWarning"
Grid.Row="2" Grid.Row="2"
VerticalAlignment="Top" VerticalAlignment="Top"
IsClosable="False" IsClosable="False"
IsOpen="False" IsTabStop="False"
IsTabStop="True" Severity="Warning">
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"> <Grid Margin="32,24,32,24">
<ProgressRing <ProgressRing
x:Name="LoadingProgressRing" x:Name="LoadingProgressRing"

View File

@ -10,7 +10,6 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; 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 RemoveInstallerHashesRegex = @"(\r\n)+## Installer Hashes(\r\n.*)+## Highlights";
private const string RemoveHotFixInstallerHashesRegex = @"(\r\n)+## Installer Hashes(\r\n.*)+$"; private const string RemoveHotFixInstallerHashesRegex = @"(\r\n)+## Installer Hashes(\r\n.*)+$";
private const RegexOptions RemoveInstallerHashesRegexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant; private const RegexOptions RemoveInstallerHashesRegexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
private bool _loadingReleaseNotes;
private static async Task<string> GetReleaseNotesMarkdown() private static async Task<string> GetReleaseNotesMarkdown()
{ {
@ -127,12 +127,19 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private async Task Reload() private async Task Reload()
{ {
if (_loadingReleaseNotes)
{
return;
}
try try
{ {
_loadingReleaseNotes = true;
ReleaseNotesMarkdown.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
LoadingProgressRing.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
string releaseNotesMarkdown = await GetReleaseNotesMarkdown(); string releaseNotesMarkdown = await GetReleaseNotesMarkdown();
ProxyWarningInfoBar.IsOpen = false;
ProxyWarningInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; ErrorInfoBar.IsOpen = false;
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
ReleaseNotesMarkdown.Text = releaseNotesMarkdown; ReleaseNotesMarkdown.Text = releaseNotesMarkdown;
ReleaseNotesMarkdown.Visibility = Microsoft.UI.Xaml.Visibility.Visible; 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); Logger.LogError("Exception when loading the release notes", httpEx);
if (httpEx.Message.Contains("407", StringComparison.CurrentCulture)) if (httpEx.Message.Contains("407", StringComparison.CurrentCulture))
{ {
ProxyWarningInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible; ProxyWarningInfoBar.IsOpen = true;
} }
else else
{ {
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible; ErrorInfoBar.IsOpen = true;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError("Exception when loading the release notes", ex); Logger.LogError("Exception when loading the release notes", ex);
ErrorInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible; ErrorInfoBar.IsOpen = true;
} }
finally finally
{ {
LoadingProgressRing.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; 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); 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>
<data name="SettingsPage_NewInfoBadge.Text" xml:space="preserve"> <data name="SettingsPage_NewInfoBadge.Text" xml:space="preserve">
<value>NEW</value> <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> </data>
</root> </root>