diff --git a/src/Files.Backend/Services/Settings/IPreferencesSettingsService.cs b/src/Files.Backend/Services/Settings/IPreferencesSettingsService.cs index 8458a86e7fee..1a46d7a57639 100644 --- a/src/Files.Backend/Services/Settings/IPreferencesSettingsService.cs +++ b/src/Files.Backend/Services/Settings/IPreferencesSettingsService.cs @@ -109,10 +109,5 @@ public interface IPreferencesSettingsService : IBaseSettingsService, INotifyProp /// A list containing all paths to tabs closed on last session. /// List LastSessionTabList { get; set; } - - /// - /// Gets or sets a value indicating whether or not to open archives in Files. - /// - bool OpenArchivesInFiles { get; set; } } } diff --git a/src/Files.Package/Package.appxmanifest b/src/Files.Package/Package.appxmanifest index 02a2e4497bb1..fb8cbecfde12 100644 --- a/src/Files.Package/Package.appxmanifest +++ b/src/Files.Package/Package.appxmanifest @@ -69,9 +69,12 @@ - + .zip + .7z + .rar + .tar diff --git a/src/Files.Shared/Extensions/LinqExtensions.cs b/src/Files.Shared/Extensions/LinqExtensions.cs index b81c82d8b66a..1ef84582314f 100644 --- a/src/Files.Shared/Extensions/LinqExtensions.cs +++ b/src/Files.Shared/Extensions/LinqExtensions.cs @@ -42,6 +42,24 @@ public static class LinqExtensions return defaultValue; } + public static async Task GetAsync(this IDictionary dictionary, TKey key, Func> defaultValueFunc) + { + if (dictionary is null || key is null) + { + return await defaultValueFunc(); + } + if (!dictionary.ContainsKey(key)) + { + var defaultValue = await defaultValueFunc(); + if (defaultValue is TValue value) + { + dictionary.Add(key, value); + } + return defaultValue; + } + return dictionary[key]; + } + public static async Task> WhereAsync(this IEnumerable source, Func> predicate) { var results = await Task.WhenAll(source.Select(async x => (x, await predicate(x)))); diff --git a/src/Files.Uwp/Filesystem/StorageItems/ZipStorageFolder.cs b/src/Files.Uwp/Filesystem/StorageItems/ZipStorageFolder.cs index 85db467ba498..04da59e5a12c 100644 --- a/src/Files.Uwp/Filesystem/StorageItems/ZipStorageFolder.cs +++ b/src/Files.Uwp/Filesystem/StorageItems/ZipStorageFolder.cs @@ -79,7 +79,6 @@ public static bool IsZipPath(string path, bool includeRoot = true) private static Dictionary defaultAppDict = new Dictionary(); public static async Task CheckDefaultZipApp(string filePath) { - IUserSettingsService userSettingsService = Ioc.Default.GetService(); Func> queryFileAssoc = async () => { var assoc = await NativeWinApiHelper.GetFileAssociationAsync(filePath); @@ -91,7 +90,7 @@ public static async Task CheckDefaultZipApp(string filePath) return true; }; var ext = System.IO.Path.GetExtension(filePath)?.ToLowerInvariant(); - return userSettingsService.PreferencesSettingsService.OpenArchivesInFiles || await defaultAppDict.Get(ext, queryFileAssoc()); + return await defaultAppDict.GetAsync(ext, queryFileAssoc); } public static IAsyncOperation FromPathAsync(string path) @@ -106,7 +105,7 @@ public static IAsyncOperation FromPathAsync(string path) if (marker is not -1) { var containerPath = path.Substring(0, marker + ext.Length); - if (await CheckDefaultZipApp(path) && CheckAccess(containerPath)) + if (CheckAccess(containerPath)) { return new ZipStorageFolder(path, containerPath); } diff --git a/src/Files.Uwp/ServicesImplementation/Settings/PreferencesSettingsService.cs b/src/Files.Uwp/ServicesImplementation/Settings/PreferencesSettingsService.cs index 334a76860bc8..438df6e9f544 100644 --- a/src/Files.Uwp/ServicesImplementation/Settings/PreferencesSettingsService.cs +++ b/src/Files.Uwp/ServicesImplementation/Settings/PreferencesSettingsService.cs @@ -140,12 +140,6 @@ public List LastSessionTabList set => Set(value); } - public bool OpenArchivesInFiles - { - get => Get(true); - set => Set(value); - } - protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e) { switch (e.SettingName) @@ -167,7 +161,6 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged case nameof(ContinueLastSessionOnStartUp): case nameof(OpenNewTabOnStartup): case nameof(AlwaysOpenNewInstance): - case nameof(OpenArchivesInFiles): Analytics.TrackEvent($"{e.SettingName} {e.NewValue}"); break; } @@ -194,7 +187,6 @@ public void ReportToAppCenter() Analytics.TrackEvent($"{nameof(ContinueLastSessionOnStartUp)}, {ContinueLastSessionOnStartUp}"); Analytics.TrackEvent($"{nameof(OpenNewTabOnStartup)}, {OpenNewTabOnStartup}"); Analytics.TrackEvent($"{nameof(AlwaysOpenNewInstance)}, {AlwaysOpenNewInstance}"); - Analytics.TrackEvent($"{nameof(OpenArchivesInFiles)}, {OpenArchivesInFiles}"); } } }