Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where properties were sometimes not displayed in the details pane #12952

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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