diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs index 3cbfbea3b828..c9e21127950e 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs @@ -14,6 +14,8 @@ namespace Files.App.Actions [GeneratedRichCommand] internal sealed partial class DecompressArchiveAction : BaseDecompressArchiveAction { + private readonly IUserSettingsService UserSettingsService = Ioc.Default.GetRequiredService(); + public override string Label => Strings.ExtractFiles.GetLocalizedResource(); @@ -81,6 +83,9 @@ public override async Task ExecuteAsync(object? parameter = null) BaseStorageFolder destinationFolder = decompressArchiveViewModel.DestinationFolder; string destinationFolderPath = decompressArchiveViewModel.DestinationFolderPath; + // Save extraction location for future use + SaveExtractionLocation(destinationFolderPath); + if (destinationFolder is null) { BaseStorageFolder parentFolder = await StorageHelpers.ToStorageItem(Path.GetDirectoryName(archive.Path) ?? string.Empty); @@ -119,5 +124,17 @@ protected override bool CanDecompressSelectedItems() return null; } + + private void SaveExtractionLocation(string path) + { + var previousArchiveExtractionLocations = UserSettingsService.GeneralSettingsService.PreviousArchiveExtractionLocations?.ToList() ?? []; + previousArchiveExtractionLocations.Remove(path); + previousArchiveExtractionLocations.Insert(0, path); + + if (previousArchiveExtractionLocations.Count > 10) + UserSettingsService.GeneralSettingsService.PreviousArchiveExtractionLocations = previousArchiveExtractionLocations.RemoveFrom(11); + else + UserSettingsService.GeneralSettingsService.PreviousArchiveExtractionLocations = previousArchiveExtractionLocations; + } } } diff --git a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs index 068f4f088fda..ff069961403a 100644 --- a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs +++ b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs @@ -55,6 +55,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty /// List PreviousSearchQueriesList { get; set; } + /// + /// Stores list of paths where archives have previously been extracted. + /// + List PreviousArchiveExtractionLocations { get; set; } + /// /// Gets or sets a value indicating which date and time format to use. /// diff --git a/src/Files.App/Dialogs/DecompressArchiveDialog.xaml b/src/Files.App/Dialogs/DecompressArchiveDialog.xaml index 732f04e7072d..2d09b523720b 100644 --- a/src/Files.App/Dialogs/DecompressArchiveDialog.xaml +++ b/src/Files.App/Dialogs/DecompressArchiveDialog.xaml @@ -12,6 +12,7 @@ CornerRadius="{StaticResource OverlayCornerRadius}" DefaultButton="Primary" HighContrastAdjustment="None" + IsPrimaryButtonEnabled="{x:Bind ViewModel.IsDestinationPathValid, Mode=OneWay}" PrimaryButtonClick="ContentDialog_PrimaryButtonClick" PrimaryButtonText="{helpers:ResourceString Name=Extract}" RequestedTheme="{x:Bind RootAppElement.RequestedTheme, Mode=OneWay}" @@ -44,13 +45,14 @@ Text="{helpers:ResourceString Name=ExtractToPath}" /> - + ItemsSource="{x:Bind ViewModel.PreviousExtractionLocations, Mode=OneWay}" + Text="{x:Bind ViewModel.DestinationFolderPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" + TextChanged="DestinationFolderPath_TextChanged" />