Browse Source

FIxed compilation errors

Krzysztof Krysiński 1 year ago
parent
commit
197087272b

+ 3 - 0
src/PixiEditor.Extensions/Common/UserPreferences/PreferencesConstants.cs

@@ -32,6 +32,9 @@ public static class PreferencesConstants
     [LocalPreferenceConstant]
     public const string AutosaveHistory = nameof(AutosaveHistory);
 
+    [LocalPreferenceConstant]
+    public const string UnsavedNextSessionFiles = nameof(UnsavedNextSessionFiles);
+
     [SyncedPreferenceConstant]
     public const string AutosaveToDocumentPath = nameof(AutosaveToDocumentPath);
     public const bool AutosaveToDocumentPathDefault = false;

+ 6 - 1
src/PixiEditor/Models/DataHolders/CrashReportAutosaveFilePathInfo.cs

@@ -1,4 +1,5 @@
 using System.IO;
+using PixiEditor.Helpers;
 
 namespace PixiEditor.Models.DataHolders;
 
@@ -7,5 +8,9 @@ public class CrashReportAutosaveFilePathInfo(string? originalPath, string? autos
     public string? OriginalPath { get; set; } = originalPath;
 
     public string? AutosavePath { get; set; } = autosavePath;
-    
+
+    public Guid? GetAutosaveGuid()
+    {
+        return AutosaveHelper.GetAutosaveGuid(AutosavePath);
+    }
 }

+ 1 - 1
src/PixiEditor/ViewModels/SubViewModels/Document/AutosaveDocumentViewModel.cs

@@ -88,7 +88,7 @@ internal class AutosaveDocumentViewModel : NotifyableObject
             Directory.CreateDirectory(Directory.GetParent(filePath)!.FullName);
             bool success = Exporter.TrySave(Document, filePath) == SaveResult.Success;
             if (success)
-                AddAutosaveHistoryEntry(AutosaveHistoryType.OnClose);
+                AddAutosaveHistoryEntry(AutosaveHistoryType.OnClose, AutosaveHistoryResult.SavedBackup);
             
             return success;
         }

+ 5 - 5
src/PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -204,7 +204,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
         
         var history = preferences.GetLocalPreference<List<AutosaveHistorySession>>(PreferencesConstants.AutosaveHistory);
         
-        // There are no autosave attempts .. but what if the user has just launched pixieditor for the first time,
+        // There are no autosave attempts ... but what if the user has just launched pixieditor for the first time,
         // and it unexpectedly closed before auto saving anything. They could've still had some files open, and they won't be reopened in this session
         // I'll say this is by design
         if (history is null || history.Count == 0)
@@ -240,13 +240,13 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
                 if (lastEntry.Type != AutosaveHistoryType.OnClose)
                 {
                     // unexpected shutdown happened, this file wasn't saved on close, but we supposedly have a backup
-                    
                 }
                 else
                 {
                     switch (lastEntry.Result)
                     {
                         case AutosaveHistoryResult.SavedBackup:
+                            
                             // load from autosave
                             break;
                         case AutosaveHistoryResult.SavedUserFile:
@@ -260,7 +260,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
                 
                 
                 
-                string path = AutosaveHelper.GetAutosavePath(entry.TempFileGuid);
+                string path = AutosaveHelper.GetAutosavePath(lastEntry.TempFileGuid);
                 if (!File.Exists(path))
                 {
                     // something happened with the file? todo try to recover backup while notifying user
@@ -274,7 +274,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
 
         }
         
-        foreach (var file in files)
+        /*foreach (var file in files)
         {
             try
             {
@@ -297,7 +297,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
             {
                 CrashHelper.SendExceptionInfoToWebhook(e);
             }
-        }
+        }*/
         
         preferences.UpdateLocalPreference(PreferencesConstants.UnsavedNextSessionFiles, Array.Empty<string>());
     }