Pārlūkot izejas kodu

Make sure not to set initialDirectory incorrectly when it is archived.

Refactor archive handling: introduce `IsArchived` property in `ArchiveExtraction`, replace `TempZipDirectory` checks with `IsArchived` across related classes for clarity.
Ruben 4 mēneši atpakaļ
vecāks
revīzija
b976e259ef

+ 2 - 1
src/PicView.Avalonia/Navigation/ImageIterator.cs

@@ -5,6 +5,7 @@ using PicView.Avalonia.ImageHandling;
 using PicView.Avalonia.Input;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
+using PicView.Core.ArchiveHandling;
 using PicView.Core.DebugTools;
 using PicView.Core.FileHandling;
 using PicView.Core.FileHistory;
@@ -55,7 +56,7 @@ public class ImageIterator : IAsyncDisposable
         FileInfo initialDirectory;
         if (Settings.Sorting.IncludeSubDirectories)
         {
-            if (!string.IsNullOrWhiteSpace(Settings.StartUp.StartUpDirectory))
+            if (!string.IsNullOrWhiteSpace(Settings.StartUp.StartUpDirectory) && !ArchiveExtraction.IsArchived)
             {
                 initialDirectory = new FileInfo(Settings.StartUp.StartUpDirectory);
             }

+ 1 - 1
src/PicView.Avalonia/Navigation/ImageLoader.cs

@@ -237,7 +237,7 @@ public static class ImageLoader
         TitleManager.SetLoadingTitle(vm);
 
         string? prevArchiveLocation = null;
-        var previousArchiveExist = !string.IsNullOrEmpty(ArchiveExtraction.TempZipDirectory);
+        var previousArchiveExist = ArchiveExtraction.IsArchived;
         if (previousArchiveExist)
         {
             prevArchiveLocation = ArchiveExtraction.TempZipDirectory;

+ 1 - 1
src/PicView.Avalonia/UI/FileHistory/FileHistoryMenuItem.cs

@@ -28,7 +28,7 @@ namespace PicView.Avalonia.UI.FileHistory
             }
 
             bool isSelected;
-            if (!string.IsNullOrWhiteSpace(ArchiveExtraction.TempZipDirectory))
+            if (ArchiveExtraction.IsArchived)
             {
                 isSelected = fileLocation == ArchiveExtraction.LastOpenedArchive;
             }

+ 2 - 0
src/PicView.Core/ArchiveHandling/ArchiveExtraction.cs

@@ -15,6 +15,8 @@ public static class ArchiveExtraction
     public static string? TempZipDirectory { get; private set; }
         
     public static string? LastOpenedArchive { get; private set; }
+    
+    public static bool IsArchived => TempZipDirectory != null;
 
     /// <summary>
     ///     Asynchronously extracts supported files from a given archive to a temporary directory.