Skip to content

Commit af0e118

Browse files
committed
Use loaded event & Add style
1 parent c241d21 commit af0e118

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Flow.Launcher/ReleaseNotesWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@
161161
Margin="15 0 20 0"
162162
HorizontalAlignment="Stretch"
163163
VerticalAlignment="Stretch"
164-
ClickAction="SafetyDisplayWithRelativePath" />
164+
ClickAction="SafetyDisplayWithRelativePath"
165+
Loaded="MarkdownViewer_Loaded" />
165166
</Grid>
166167
</Border>
167168
</Grid>

Flow.Launcher/ReleaseNotesWindow.xaml.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows;
1010
using System.Windows.Input;
1111
using Flow.Launcher.Infrastructure.Http;
12+
using MdXaml;
1213

1314
namespace Flow.Launcher
1415
{
@@ -21,11 +22,9 @@ public ReleaseNotesWindow()
2122

2223
#region Window Events
2324

24-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]
25-
private async void Window_Loaded(object sender, RoutedEventArgs e)
25+
private void Window_Loaded(object sender, RoutedEventArgs e)
2626
{
2727
RefreshMaximizeRestoreButton();
28-
MarkdownViewer.Markdown = await GetReleaseNotesMarkdownAsync();
2928
}
3029

3130
private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e)
@@ -82,6 +81,11 @@ private void Window_StateChanged(object sender, EventArgs e)
8281
private static async Task<string> GetReleaseNotesMarkdownAsync()
8382
{
8483
var releaseNotesJSON = await Http.GetStringAsync("https://api.github.com/repos/Flow-Launcher/Flow.Launcher/releases");
84+
85+
if (string.IsNullOrEmpty(releaseNotesJSON))
86+
{
87+
return string.Empty;
88+
}
8589
var releases = JsonSerializer.Deserialize<List<GitHubReleaseInfo>>(releaseNotesJSON);
8690

8791
// Get the latest releases
@@ -145,5 +149,12 @@ private sealed class GitHubReleaseInfo
145149
private static partial Regex ImageUnitRegex();
146150

147151
#endregion
152+
153+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]
154+
private async void MarkdownViewer_Loaded(object sender, RoutedEventArgs e)
155+
{
156+
MarkdownViewer.MarkdownStyle = MarkdownStyle.GithubLike;
157+
MarkdownViewer.Markdown = await GetReleaseNotesMarkdownAsync();
158+
}
148159
}
149160
}

0 commit comments

Comments
 (0)