Skip to content

Commit

Permalink
Added the title of an release to the informations when showing an new…
Browse files Browse the repository at this point in the history
… version.
  • Loading branch information
Luca Auer authored and Luca Auer committed Aug 18, 2018
1 parent bb43596 commit 0a6a282
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Image sort.Communication/UpdaterConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ public class UpdaterConstants
/// Signals that the new version number of the update is outputted in the next line.
/// </summary>
public const string UpdateVersion = "new_update_version";
/// <summary>
/// Signals that the title of the new version is going to be outputted in the next line.
/// </summary>
public const string UpdateTitle = "transmitting_title";
}
}
8 changes: 7 additions & 1 deletion Image sort.UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ await Task.Run(async () =>
{
string changelog = "";
string version = "unknown";
string title = "";

// and read the output till the end.
while (!output.EndOfStream)
Expand All @@ -1731,7 +1732,7 @@ await Dispatcher.InvokeAsync(async () =>
{
// Create a new UpdateDialog to ask for user consent.
var dlg = new UpdateDialog() {
ChangelogMarkdown = changelog,
ChangelogMarkdown = $"# {title}{Environment.NewLine}{changelog}",
Version = version,
Title = AppResources.UpdateConsentQuestion
};
Expand Down Expand Up @@ -1787,6 +1788,11 @@ await Dispatcher.Invoke(() => this.ShowMessageAsync(AppResources.RateLimitExceed
{
version = output.ReadLine();
}
// if the title is going to be set, then read it.
else if (line == UpdaterConstants.UpdateTitle)
{
title = output.ReadLine();
}
// Tell the user that an error occured, if it occured.
else if (line == UpdaterConstants.Error)
{
Expand Down
2 changes: 1 addition & 1 deletion Image sort.UI/UpdateDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<TextBlock Margin="0 10 0 0" Text="{x:Static res:AppResources.UpdateWhatsNew}"
FontSize="18" TextWrapping="Wrap" Grid.Row="1" FontWeight="Bold"/>
<Border BorderThickness="2" BorderBrush="Black" Margin="0 10 0 0" Grid.Row="2">
<markdigwpf:MarkdownViewer Name="ChangelogViewer" MaxHeight="150" TabIndex="2" Padding="5"/>
<markdigwpf:MarkdownViewer Name="ChangelogViewer" MaxHeight="200" TabIndex="2" Padding="5"/>
</Border>
<!-- Warning the user that the app will close when giving consent -->
<TextBlock Text="{x:Static res:AppResources.UpdateWillCloseAppMessage}"
Expand Down
10 changes: 10 additions & 0 deletions Image sort.Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private static void InitUpdating(Release release)
{
string version = release.TagName;
string releaseBody = release.Body;
string releaseTitle = release.Name;
if (releaseBody != null)
{
// Signal that the changelog is going to be transmitted.
Expand All @@ -159,6 +160,15 @@ private static void InitUpdating(Release release)
Console.WriteLine(version);
}

if (releaseTitle != null)
{
// Signal the main app that the title of the new version is going to be transmitted
Console.WriteLine(UpdaterConstants.UpdateTitle);

// Send the title
Console.WriteLine(releaseTitle);
}

// asks the parent process for user consent
Console.WriteLine(UpdaterConstants.UserConsent);
// asks if consent is given (yes the true : false is for performance optimization)
Expand Down

0 comments on commit 0a6a282

Please sign in to comment.