From 88d9753ec42fdca4cee071ea5c58ddc72e2be604 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sat, 17 Jul 2021 10:54:06 +0200 Subject: [PATCH 1/3] Do not check for equality when setting property --- .../Models/Settings/BaseJsonSettingsModel.cs | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/Files/Models/Settings/BaseJsonSettingsModel.cs b/Files/Models/Settings/BaseJsonSettingsModel.cs index 42a5bdf7ce93..7b9995d9e4e4 100644 --- a/Files/Models/Settings/BaseJsonSettingsModel.cs +++ b/Files/Models/Settings/BaseJsonSettingsModel.cs @@ -173,42 +173,6 @@ protected virtual bool Set(TValue value, [CallerMemberName] string prope { try { - // Check if caching is enabled - if (isCachingEnabled) - { - // If cache contains the setting... - if (settingsCache.ContainsKey(propertyName)) - { - TValue settingValue; - - // Get the object - object settingObject = settingsCache[propertyName]; - - // Check if it's a JToken object - if (settingObject is JToken jtoken) - { - // Get the value from JToken - settingValue = jtoken.ToObject(); - } - else - { - // Otherwise, it is TValue, get the value - settingValue = (TValue)settingObject; - } - - // Compare the setting and the new value - if (EqualityComparer.Default.Equals(value, settingValue)) - { - // Both are equal meaning the cache doesn't have to be reloaded, return - return false; - } - - // The values aren't equal, continue, to update the file and cache - } - - // The value doesn't exist, continue, to update the file and cache - } - // If cache doesn't contain the setting... if (!settingsCache.ContainsKey(propertyName)) { From 75cd8e2acfbe614aa11a2f075a65f40da3c3f2eb Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sat, 17 Jul 2021 11:12:21 +0200 Subject: [PATCH 2/3] Remove ServiceConnection from ModernShellPage (unused) --- Files/Views/ColumnShellPage.xaml.cs | 13 +------------ Files/Views/ModernShellPage.xaml.cs | 14 +------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Files/Views/ColumnShellPage.xaml.cs b/Files/Views/ColumnShellPage.xaml.cs index e9a152d833ad..5c7ec792904d 100644 --- a/Files/Views/ColumnShellPage.xaml.cs +++ b/Files/Views/ColumnShellPage.xaml.cs @@ -182,8 +182,6 @@ public ColumnShellPage() SystemNavigationManager.GetForCurrentView().BackRequested += ColumnShellPage_BackRequested; App.DrivesManager.PropertyChanged += DrivesManager_PropertyChanged; - - AppServiceConnectionHelper.ConnectionChanged += AppServiceConnectionHelper_ConnectionChanged; } void InitToolbarCommands() @@ -494,8 +492,6 @@ private void OnNavigationParamsChanged() public static readonly DependencyProperty NavParamsProperty = DependencyProperty.Register("NavParams", typeof(string), typeof(ColumnShellPage), new PropertyMetadata(null)); - public NamedPipeAsAppServiceConnection ServiceConnection { get; private set; } - private TabItemArguments tabItemArguments; public TabItemArguments TabItemArguments @@ -535,7 +531,7 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - private async void Page_Loaded(object sender, RoutedEventArgs e) + private void Page_Loaded(object sender, RoutedEventArgs e) { FilesystemViewModel = new ItemViewModel(InstanceViewModel?.FolderSettings); FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; @@ -544,7 +540,6 @@ private async void Page_Loaded(object sender, RoutedEventArgs e) FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; OnNavigationParamsChanged(); - ServiceConnection = await AppServiceConnectionHelper.Instance; this.Loaded -= Page_Loaded; } @@ -803,12 +798,6 @@ public void Dispose() FilesystemViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent; FilesystemViewModel.Dispose(); } - AppServiceConnectionHelper.ConnectionChanged -= AppServiceConnectionHelper_ConnectionChanged; - } - - private async void AppServiceConnectionHelper_ConnectionChanged(object sender, Task e) - { - ServiceConnection = await e; } private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs e) diff --git a/Files/Views/ModernShellPage.xaml.cs b/Files/Views/ModernShellPage.xaml.cs index 6cafa38c2784..4bb37ecf1b46 100644 --- a/Files/Views/ModernShellPage.xaml.cs +++ b/Files/Views/ModernShellPage.xaml.cs @@ -188,8 +188,6 @@ public ModernShellPage() SystemNavigationManager.GetForCurrentView().BackRequested += ModernShellPage_BackRequested; App.DrivesManager.PropertyChanged += DrivesManager_PropertyChanged; - - AppServiceConnectionHelper.ConnectionChanged += AppServiceConnectionHelper_ConnectionChanged; } void InitToolbarCommands() @@ -522,8 +520,6 @@ private void OnNavigationParamsChanged() public static readonly DependencyProperty NavParamsProperty = DependencyProperty.Register("NavParams", typeof(string), typeof(ModernShellPage), new PropertyMetadata(null)); - public NamedPipeAsAppServiceConnection ServiceConnection { get; private set; } - private TabItemArguments tabItemArguments; public TabItemArguments TabItemArguments @@ -563,7 +559,7 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - private async void Page_Loaded(object sender, RoutedEventArgs e) + private void Page_Loaded(object sender, RoutedEventArgs e) { FilesystemViewModel = new ItemViewModel(InstanceViewModel?.FolderSettings); FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified; @@ -572,7 +568,6 @@ private async void Page_Loaded(object sender, RoutedEventArgs e) FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated; FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent; OnNavigationParamsChanged(); - ServiceConnection = await AppServiceConnectionHelper.Instance; this.Loaded -= Page_Loaded; } @@ -945,13 +940,6 @@ public void Dispose() { disposableContent?.Dispose(); } - - AppServiceConnectionHelper.ConnectionChanged -= AppServiceConnectionHelper_ConnectionChanged; - } - - private async void AppServiceConnectionHelper_ConnectionChanged(object sender, Task e) - { - ServiceConnection = await e; } private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs e) From 4bb05fb695d2f309c3a7eddaa74056f347fad372 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Sat, 17 Jul 2021 11:27:05 +0200 Subject: [PATCH 3/3] Fixes an issue where the folder item count was not updated --- Files/ViewModels/ItemViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Files/ViewModels/ItemViewModel.cs b/Files/ViewModels/ItemViewModel.cs index 029a1cefae9a..f992b8983a15 100644 --- a/Files/ViewModels/ItemViewModel.cs +++ b/Files/ViewModels/ItemViewModel.cs @@ -1127,6 +1127,7 @@ private async void RapidAddItemsToCollectionAsync(string path, string previousDi } finally { + DirectoryInfoUpdated?.Invoke(this, EventArgs.Empty); // Make sure item count is updated enumFolderSemaphore.Release(); itemLoadEvent.Set(); }