-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add updater and fix build-script to only include the files
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Windows; | ||
using Microsoft.Extensions.Hosting; | ||
using Onova; | ||
|
||
namespace ChatPrisma.HostedServices; | ||
|
||
public class UpdaterHostedService(IUpdateManager updateManager, Application app) : IHostedService | ||
{ | ||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
var result = await updateManager.CheckForUpdatesAsync(cancellationToken); | ||
if (result is { CanUpdate: true, LastVersion: not null }) | ||
{ | ||
await updateManager.PrepareUpdateAsync(result.LastVersion, cancellationToken: cancellationToken); | ||
|
||
var updateResult = MessageBox.Show("Update available!, Wanna update now?", "Title", MessageBoxButton.YesNo); | ||
if (updateResult == MessageBoxResult.Yes) | ||
{ | ||
updateManager.LaunchUpdater(result.LastVersion); | ||
app.Shutdown(); | ||
} | ||
} | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} |