Implement all electron-updater events

This commit is contained in:
Gregor Biswanger
2019-05-23 02:59:30 +02:00
parent 0cede6131e
commit a2ada57292
6 changed files with 302 additions and 4 deletions

View File

@@ -10,6 +10,23 @@ namespace ElectronNET.WebApp.Controllers
{
if (HybridSupport.IsElectronActive)
{
Electron.AutoUpdater.OnError += (message) => Electron.Dialog.ShowErrorBox("Error", message);
Electron.AutoUpdater.OnCheckingForUpdate += async () => await Electron.Dialog.ShowMessageBoxAsync("Checking for Update");
Electron.AutoUpdater.OnUpdateNotAvailable += async (info) => await Electron.Dialog.ShowMessageBoxAsync("Update not available");
Electron.AutoUpdater.OnUpdateAvailable += async (info) => await Electron.Dialog.ShowMessageBoxAsync("Update available" + info.Version);
Electron.AutoUpdater.OnDownloadProgress += (info) =>
{
var message1 = "Download speed: " + info.BytesPerSecond + "\n<br/>";
var message2 = "Downloaded " + info.Percent + "%" + "\n<br/>";
var message3 = $"({info.Transferred}/{info.Total})" + "\n<br/>";
var message4 = "Progress: " + info.Progress + "\n<br/>";
var information = message1 + message2 + message3 + message4;
var mainWindow = Electron.WindowManager.BrowserWindows.First();
Electron.IpcMain.Send(mainWindow, "auto-update-reply", information);
};
Electron.AutoUpdater.OnUpdateDownloaded += async (info) => await Electron.Dialog.ShowMessageBoxAsync("Update complete!" + info.Version);
Electron.IpcMain.On("auto-update", async (args) =>
{
// Electron.NET CLI Command for deploy: