Skip to content

Commit

Permalink
minor changes and retry button
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Mar 8, 2025
1 parent 9a4fdad commit e66c8a5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<Grid Margin="0,24,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
Expand Down Expand Up @@ -85,17 +86,41 @@
VerticalAlignment="Top"
IsClosable="False"
IsTabStop="False"
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
x:Name="ProxyWarningInfoBar"
x:Uid="Oobe_WhatsNew_ProxyAuthenticationWarning"
Grid.Row="2"
VerticalAlignment="Top"
IsClosable="False"
IsTabStop="False"
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">
<ProgressRing
x:Name="LoadingProgressRing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private bool GetShowDataDiagnosticsInfoBar()
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()
{
Expand Down Expand Up @@ -126,11 +127,19 @@ private static async Task<string> GetReleaseNotesMarkdown()

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();
SetInfoBar(ProxyWarningInfoBar, false);
SetInfoBar(ErrorInfoBar, false);
ProxyWarningInfoBar.IsOpen = false;
ErrorInfoBar.IsOpen = false;

ReleaseNotesMarkdown.Text = releaseNotesMarkdown;
ReleaseNotesMarkdown.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
Expand All @@ -141,21 +150,22 @@ private async Task Reload()
Logger.LogError("Exception when loading the release notes", httpEx);
if (httpEx.Message.Contains("407", StringComparison.CurrentCulture))
{
SetInfoBar(ProxyWarningInfoBar, true);
ProxyWarningInfoBar.IsOpen = true;
}
else
{
SetInfoBar(ErrorInfoBar, true);
ErrorInfoBar.IsOpen = true;
}
}
catch (Exception ex)
{
Logger.LogError("Exception when loading the release notes", ex);
SetInfoBar(ErrorInfoBar, true);
ErrorInfoBar.IsOpen = true;
}
finally
{
LoadingProgressRing.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
_loadingReleaseNotes = false;
}
}

Expand Down Expand Up @@ -247,10 +257,9 @@ private void DataDiagnostics_OpenSettings_Click(Microsoft.UI.Xaml.Documents.Hype
Common.UI.SettingsDeepLink.OpenSettings(Common.UI.SettingsDeepLink.SettingsWindow.Overview, true);
}

private void SetInfoBar(InfoBar infoBar, bool open)
private async void LoadReleaseNotes_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
infoBar.IsOpen = open;
infoBar.IsTabStop = open;
await Reload();
}
}
}
8 changes: 7 additions & 1 deletion src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4895,6 +4895,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>

0 comments on commit e66c8a5

Please sign in to comment.