Skip to content

Commit

Permalink
Release-0.9.9.27
Browse files Browse the repository at this point in the history
Release 0.9.9.27
Changelog viewer
  • Loading branch information
AlexMacocian authored Apr 11, 2024
2 parents 28c3b2f + a96c6c3 commit 569ce1e
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 3 deletions.
1 change: 1 addition & 0 deletions Daybreak/Configuration/ProjectConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public override void RegisterViews(IViewProducer viewProducer)
viewProducer.RegisterView<SettingsSynchronizationView>();
viewProducer.RegisterView<TeamBuildTemplateView>();
viewProducer.RegisterView<EventCalendarView>();
viewProducer.RegisterView<UpdateConfirmationView>();
}

public override void RegisterStartupActions(IStartupActionProducer startupActionProducer)
Expand Down
2 changes: 1 addition & 1 deletion Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.9.26</Version>
<Version>0.9.9.27</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
15 changes: 15 additions & 0 deletions Daybreak/Services/Updater/ApplicationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ public async Task<IEnumerable<Version>> GetVersions()
return new List<Version>();
}

public async Task<string?> GetChangelog(Version version)
{
var changeLogResponse = await this.httpClient.GetAsync(
BlobStorageUrl
.Replace(VersionTag, version.ToString().Replace(".", "-"))
.Replace(FileTag, "changelog.txt"));

if (!changeLogResponse.IsSuccessStatusCode)
{
return default;
}

return await changeLogResponse.Content.ReadAsStringAsync();
}

public void PeriodicallyCheckForUpdates()
{
System.Extensions.TaskExtensions.RunPeriodicAsync(async () =>
Expand Down
1 change: 1 addition & 0 deletions Daybreak/Services/Updater/IApplicationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface IApplicationUpdater : IApplicationLifetimeService
Task<bool> UpdateAvailable();
Task<bool> DownloadUpdate(Version version, UpdateStatus updateStatus);
Task<bool> DownloadLatestUpdate(UpdateStatus updateStatus);
Task<string?> GetChangelog(Version version);
}
2 changes: 1 addition & 1 deletion Daybreak/Services/Updater/UpdateNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public void OpenNotification(Notification notification)
}

version.HasPrefix = true;
this.viewManager.ShowView<UpdateView>(version);
this.viewManager.ShowView<UpdateConfirmationView>(version);
}
}
81 changes: 81 additions & 0 deletions Daybreak/Views/UpdateConfirmationView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<UserControl x:Class="Daybreak.Views.UpdateConfirmationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:buttons="clr-namespace:Daybreak.Controls.Buttons"
xmlns:local="clr-namespace:Daybreak.Views"
Loaded="UserControl_Loaded"
x:Name="_this"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Background="{StaticResource Daybreak.Brushes.Background}"
MaxWidth="600">
<WrapPanel HorizontalAlignment="Center"
Margin="10">
<TextBlock HorizontalAlignment="Center"
Text="Daybreak "
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
FontSize="20"/>
<TextBlock HorizontalAlignment="Center"
Text="{Binding ElementName=_this, Path=Version, Mode=OneWay}"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
FontSize="20"/>
<TextBlock HorizontalAlignment="Center"
Text=" changelog"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
FontSize="20"/>
</WrapPanel>
<ScrollViewer MaxHeight="300"
VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center">
<TextBox Text="{Binding ElementName=_this, Path=ChangeLog, Mode=OneWay}"
IsReadOnly="True"
FontSize="14"/>
</ScrollViewer>
<TextBlock HorizontalAlignment="Center"
Text="Do you want to download this update?"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
FontSize="20"
Margin="10"/>
<Grid MaxWidth="600"
Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<buttons:HighlightButton Title="No"
Grid.Column="0"
HorizontalAlignment="Center"
Height="30"
Width="60"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
FontSize="16"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Background="{StaticResource MahApps.Brushes.ThemeBackground}"
HighlightColor="{StaticResource MahApps.Brushes.Accent}"
BorderBrush="{StaticResource MahApps.Brushes.ThemeForeground}"
BorderThickness="1"
Clicked="NoButton_Clicked"
ToolTip="Cancel"/>
<buttons:HighlightButton Title="Yes"
Grid.Column="1"
HorizontalAlignment="Center"
Height="30"
Width="60"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
FontSize="16"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Background="{StaticResource MahApps.Brushes.ThemeBackground}"
BorderBrush="{StaticResource MahApps.Brushes.ThemeForeground}"
BorderThickness="1"
HighlightColor="{StaticResource MahApps.Brushes.Accent}"
Clicked="YesButton_Clicked"
ToolTip="Restart"/>
</Grid>
</StackPanel>
</UserControl>
57 changes: 57 additions & 0 deletions Daybreak/Views/UpdateConfirmationView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Daybreak.Models.Versioning;
using Daybreak.Services.Navigation;
using Daybreak.Services.Updater;
using System.Core.Extensions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Extensions;

namespace Daybreak.Views;
/// <summary>
/// Interaction logic for UpdateDetailsView.xaml
/// </summary>
public partial class UpdateConfirmationView : UserControl
{
private readonly IViewManager viewManager;
private readonly IApplicationUpdater applicationUpdater;

[GenerateDependencyProperty]
public Version version = default!;

[GenerateDependencyProperty]
public string changeLog = default!;

public UpdateConfirmationView(
IViewManager viewManager,
IApplicationUpdater applicationUpdater)
{
this.viewManager = viewManager.ThrowIfNull();
this.applicationUpdater = applicationUpdater.ThrowIfNull();
this.InitializeComponent();
}

private async void UserControl_Loaded(object _, RoutedEventArgs e)
{
if (this.DataContext is not Version version)
{
return;
}

this.Version = version;
var maybeChangelog = await this.applicationUpdater.GetChangelog(version);
if (maybeChangelog is string changeLog)
{
this.ChangeLog = changeLog.Replace("<br />", string.Empty);
}
}

private void YesButton_Clicked(object sender, System.EventArgs e)
{
this.viewManager.ShowView<UpdateView>(this.Version);
}

private void NoButton_Clicked(object sender, System.EventArgs e)
{
this.viewManager.ShowView<LauncherView>();
}
}
2 changes: 1 addition & 1 deletion Daybreak/Views/VersionManagementView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ private void DesiredVersion_DownloadButton_Clicked(object sender, EventArgs e)
return;
}

this.viewManager.ShowView<UpdateView>(desiredVersion);
this.viewManager.ShowView<UpdateConfirmationView>(desiredVersion);
}
}

0 comments on commit 569ce1e

Please sign in to comment.