Browse Source

Added messagebox asking for update on every boot up

flabbet 4 years ago
parent
commit
15f97a4099

+ 1 - 1
PixiEditor.UpdateModule/UpdateChecker.cs

@@ -20,7 +20,7 @@ namespace PixiEditor.UpdateModule
 
         public ReleaseInfo LatestReleaseInfo { get; private set; }
 
-        private string CurrentVersionTag { get; }
+        public string CurrentVersionTag { get; }
 
         /// <summary>
         ///     Compares version strings and returns true if newVer > originalVer.

+ 5 - 2
PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -38,6 +38,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             {
                 updateReadyToInstall = value;
                 RaisePropertyChanged(nameof(UpdateReadyToInstall));
+                if (value)
+                {
+                    VersionText = $"to install update (current {UpdateChecker.CurrentVersionTag})"; // Button shows "Restart" before this text
+                }
             }
         }
 
@@ -70,8 +74,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                     {
                         await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
                     }
-
-                    VersionText = "to install update"; // Button shows "Restart" before this text
+                    
                     UpdateReadyToInstall = true;
                     return true;
                 }

+ 16 - 24
PixiEditor/Views/MainWindow.xaml.cs

@@ -77,13 +77,22 @@ namespace PixiEditor
             bool updateExeExists = updateExeFiles.Length > 0;
 
             string updaterPath = Path.Join(dir, "PixiEditor.UpdateInstaller.exe");
-            if (updateZipExists && File.Exists(updaterPath))
-            {
-                InstallHeadless(updaterPath);
-            }
-            else if (updateExeExists)
+
+            if (updateZipExists || updateExeExists)
             {
-                OpenExeInstaller(updateExeFiles[0]);
+                ViewModelMain.Current.UpdateSubViewModel.UpdateReadyToInstall = true;
+                var result = ConfirmationDialog.Show("Update is ready to install. Do you want to install it now?");
+                if (result == Models.Enums.ConfirmationType.Yes)
+                {
+                    if (updateZipExists && File.Exists(updaterPath))
+                    {
+                        InstallHeadless(updaterPath);
+                    }
+                    else if (updateExeExists)
+                    {
+                        OpenExeInstaller(updateExeFiles[0]);
+                    }
+                }
             }
         }
 
@@ -108,31 +117,14 @@ namespace PixiEditor
         {
             bool alreadyUpdated = AssemblyHelper.GetCurrentAssemblyVersion() ==
                     updateExeFile.Split('-')[1].Split(".exe")[0];
-            string triedInstallFilePath = Path.Join(
-                UpdateDownloader.DownloadLocation,
-                Path.GetFileNameWithoutExtension(updateExeFile) + "restartedToUpdate.txt");
 
             if (!alreadyUpdated)
             {
-                if (!File.Exists(triedInstallFilePath))
-                {
-                    RestartToUpdate(updateExeFile);
-                    File.Create(triedInstallFilePath);
-                }
-                else
-                {
-                   var result = ConfirmationDialog.Show("Update is ready to install. Do you want to install it now?");
-
-                   if (result == Models.Enums.ConfirmationType.Yes)
-                   {
-                        RestartToUpdate(updateExeFile);
-                   }
-                }
+                RestartToUpdate(updateExeFile);
             }
             else
             {
                 File.Delete(updateExeFile);
-                File.Delete(triedInstallFilePath);
             }
         }