Skip to content

Commit

Permalink
Fix: Fixed issue where properties were sometimes not displayed in the…
Browse files Browse the repository at this point in the history
… details pane (#12952)
  • Loading branch information
hishitetsu authored Jul 16, 2023
1 parent 0c58a82 commit b72e2b1
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IContentPageContext>();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -353,7 +345,6 @@ private async Task LoadBasicPreviewAsync()

public void Dispose()
{
userSettingsService.OnSettingChangedEvent -= UserSettingsService_OnSettingChangedEvent;
previewSettingsService.PropertyChanged -= PreviewSettingsService_OnPropertyChangedEvent;
}
}
Expand Down

0 comments on commit b72e2b1

Please sign in to comment.