From b72e2b1fef4c8ced3922b6f2877fc8fd0f30ce68 Mon Sep 17 00:00:00 2001 From: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Date: Mon, 17 Jul 2023 02:36:00 +0900 Subject: [PATCH] Fix: Fixed issue where properties were sometimes not displayed in the details pane (#12952) --- .../UserControls/PreviewPaneViewModel.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs index 7915a9ab7fcd..54e5fcd03d62 100644 --- a/src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs @@ -14,8 +14,6 @@ namespace Files.App.ViewModels.UserControls { public class PreviewPaneViewModel : ObservableObject, IDisposable { - private readonly IUserSettingsService userSettingsService; - private readonly IPreviewPaneSettingsService previewSettingsService; private readonly IContentPageContext contentPageContextService; @@ -69,16 +67,14 @@ public UIElement PreviewPaneContent set => SetProperty(ref previewPaneContent, value); } - public PreviewPaneViewModel(IUserSettingsService userSettings, IPreviewPaneSettingsService previewSettings, IContentPageContext contentPageContextService = null) + public PreviewPaneViewModel(IPreviewPaneSettingsService previewSettings, IContentPageContext contentPageContextService = null) { - userSettingsService = userSettings; previewSettingsService = previewSettings; ShowPreviewOnlyInvoked = new RelayCommand(async () => await UpdateSelectedItemPreview()); IsEnabled = previewSettingsService.IsEnabled; - userSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent; previewSettingsService.PropertyChanged += PreviewSettingsService_OnPropertyChangedEvent; this.contentPageContextService = contentPageContextService ?? Ioc.Default.GetRequiredService(); @@ -313,18 +309,14 @@ public async Task UpdateSelectedItemPreview(bool downloadItem = false) public ICommand ShowPreviewOnlyInvoked { get; } - private async void UserSettingsService_OnSettingChangedEvent(object sender, SettingChangedEventArgs e) + private async void PreviewSettingsService_OnPropertyChangedEvent(object sender, PropertyChangedEventArgs e) { - if (e.SettingName is nameof(IPreviewPaneSettingsService.ShowPreviewOnly)) + if (e.PropertyName is nameof(IPreviewPaneSettingsService.ShowPreviewOnly)) { // The preview will need refreshing as the file details won't be accurate await UpdateSelectedItemPreview(); } - } - - private void PreviewSettingsService_OnPropertyChangedEvent(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName is nameof(IPreviewPaneSettingsService.IsEnabled)) + else if (e.PropertyName is nameof(IPreviewPaneSettingsService.IsEnabled)) { var newEnablingStatus = previewSettingsService.IsEnabled; if (isEnabled != newEnablingStatus) @@ -353,7 +345,6 @@ private async Task LoadBasicPreviewAsync() public void Dispose() { - userSettingsService.OnSettingChangedEvent -= UserSettingsService_OnSettingChangedEvent; previewSettingsService.PropertyChanged -= PreviewSettingsService_OnPropertyChangedEvent; } }