diff --git a/Daybreak/Configuration/ProjectConfiguration.cs b/Daybreak/Configuration/ProjectConfiguration.cs index 7e8a81b1..3dcf5e17 100644 --- a/Daybreak/Configuration/ProjectConfiguration.cs +++ b/Daybreak/Configuration/ProjectConfiguration.cs @@ -333,6 +333,7 @@ public override void RegisterViews(IViewProducer viewProducer) viewProducer.RegisterView(); viewProducer.RegisterView(); viewProducer.RegisterView(); + viewProducer.RegisterView(); } public override void RegisterStartupActions(IStartupActionProducer startupActionProducer) diff --git a/Daybreak/Daybreak.csproj b/Daybreak/Daybreak.csproj index b6bc0a4d..6cbc129b 100644 --- a/Daybreak/Daybreak.csproj +++ b/Daybreak/Daybreak.csproj @@ -11,7 +11,7 @@ preview Daybreak.ico true - 0.9.9.26 + 0.9.9.27 true cfb2a489-db80-448d-a969-80270f314c46 True diff --git a/Daybreak/Services/Updater/ApplicationUpdater.cs b/Daybreak/Services/Updater/ApplicationUpdater.cs index 939e03fc..ea915785 100644 --- a/Daybreak/Services/Updater/ApplicationUpdater.cs +++ b/Daybreak/Services/Updater/ApplicationUpdater.cs @@ -158,6 +158,21 @@ public async Task> GetVersions() return new List(); } + public async Task 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 () => diff --git a/Daybreak/Services/Updater/IApplicationUpdater.cs b/Daybreak/Services/Updater/IApplicationUpdater.cs index fc63432b..0503f349 100644 --- a/Daybreak/Services/Updater/IApplicationUpdater.cs +++ b/Daybreak/Services/Updater/IApplicationUpdater.cs @@ -15,4 +15,5 @@ public interface IApplicationUpdater : IApplicationLifetimeService Task UpdateAvailable(); Task DownloadUpdate(Version version, UpdateStatus updateStatus); Task DownloadLatestUpdate(UpdateStatus updateStatus); + Task GetChangelog(Version version); } diff --git a/Daybreak/Services/Updater/UpdateNotificationHandler.cs b/Daybreak/Services/Updater/UpdateNotificationHandler.cs index a1605cc3..e9ff10e8 100644 --- a/Daybreak/Services/Updater/UpdateNotificationHandler.cs +++ b/Daybreak/Services/Updater/UpdateNotificationHandler.cs @@ -24,6 +24,6 @@ public void OpenNotification(Notification notification) } version.HasPrefix = true; - this.viewManager.ShowView(version); + this.viewManager.ShowView(version); } } diff --git a/Daybreak/Views/UpdateConfirmationView.xaml b/Daybreak/Views/UpdateConfirmationView.xaml new file mode 100644 index 00000000..ad982afd --- /dev/null +++ b/Daybreak/Views/UpdateConfirmationView.xaml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Daybreak/Views/UpdateConfirmationView.xaml.cs b/Daybreak/Views/UpdateConfirmationView.xaml.cs new file mode 100644 index 00000000..32fd584d --- /dev/null +++ b/Daybreak/Views/UpdateConfirmationView.xaml.cs @@ -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; +/// +/// Interaction logic for UpdateDetailsView.xaml +/// +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("
", string.Empty); + } + } + + private void YesButton_Clicked(object sender, System.EventArgs e) + { + this.viewManager.ShowView(this.Version); + } + + private void NoButton_Clicked(object sender, System.EventArgs e) + { + this.viewManager.ShowView(); + } +} diff --git a/Daybreak/Views/VersionManagementView.xaml.cs b/Daybreak/Views/VersionManagementView.xaml.cs index 1c21728a..dea5b359 100644 --- a/Daybreak/Views/VersionManagementView.xaml.cs +++ b/Daybreak/Views/VersionManagementView.xaml.cs @@ -81,6 +81,6 @@ private void DesiredVersion_DownloadButton_Clicked(object sender, EventArgs e) return; } - this.viewManager.ShowView(desiredVersion); + this.viewManager.ShowView(desiredVersion); } }