Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 24 additions & 4 deletions src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
using Files.App.UserControls.FilePreviews;
using Files.App.ViewModels.Previews;
using Files.Shared.Helpers;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Sentry;
using Windows.Storage;

namespace Files.App.ViewModels.UserControls
{
public sealed class InfoPaneViewModel : ObservableObject, IDisposable
{
private IInfoPaneSettingsService infoPaneSettingsService { get; } = Ioc.Default.GetRequiredService<IInfoPaneSettingsService>();
private IGeneralSettingsService generalSettingsService { get; } = Ioc.Default.GetRequiredService<IGeneralSettingsService>();
private IContentPageContext contentPageContext { get; } = Ioc.Default.GetRequiredService<IContentPageContext>();

private CancellationTokenSource loadCancellationTokenSource;
Expand Down Expand Up @@ -136,12 +139,29 @@ private async void ContentPageContext_PropertyChanged(object? sender, PropertyCh

SelectedItem = tempSelectedItem;

if (!App.AppModel.IsMainWindowClosed)
try
{
var shouldUpdatePreview = ((MainWindow.Instance.Content as Frame)?.Content as MainPage)?.ViewModel.ShouldPreviewPaneBeActive;
if (shouldUpdatePreview == true)
_ = UpdateSelectedItemPreviewAsync();
if (!App.AppModel.IsMainWindowClosed)
{
var shouldUpdatePreview = ((MainWindow.Instance.Content as Frame)?.Content as MainPage)?.ViewModel.ShouldPreviewPaneBeActive;
if (shouldUpdatePreview == true)
_ = UpdateSelectedItemPreviewAsync();
}
}
catch (Exception ex)
{
// Handle exception in case WinUI Windows is closed
// (see https://github.com/files-community/Files/issues/15599)

SentrySdk.CaptureException(ex, scope =>
{
scope.User.Id = generalSettingsService.UserId;
scope.Level = SentryLevel.Warning;
});

App.Logger.LogWarning(ex, ex.Message);
}

break;
}
}
Expand Down
34 changes: 26 additions & 8 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Navigation;
using Sentry;
using System.Data;
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
Expand All @@ -25,6 +26,7 @@ namespace Files.App.Views
{
public sealed partial class MainPage : Page
{
private IGeneralSettingsService generalSettingsService { get; } = Ioc.Default.GetRequiredService<IGeneralSettingsService>();
public IUserSettingsService UserSettingsService { get; }

public ICommandManager Commands { get; }
Expand Down Expand Up @@ -442,16 +444,32 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl

private void LoadPaneChanged()
{
var isHomePage = !(SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false);
var isMultiPane = SidebarAdaptiveViewModel.PaneHolder?.IsMultiPaneActive ?? false;
var isBigEnough = !App.AppModel.IsMainWindowClosed &&
(MainWindow.Instance.Bounds.Width > 450 && MainWindow.Instance.Bounds.Height > 450 || RootGrid.ActualWidth > 700 && MainWindow.Instance.Bounds.Height > 360);
try
{
var isHomePage = !(SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false);
var isMultiPane = SidebarAdaptiveViewModel.PaneHolder?.IsMultiPaneActive ?? false;
var isBigEnough = !App.AppModel.IsMainWindowClosed &&
(MainWindow.Instance.Bounds.Width > 450 && MainWindow.Instance.Bounds.Height > 450 || RootGrid.ActualWidth > 700 && MainWindow.Instance.Bounds.Height > 360);

ViewModel.ShouldPreviewPaneBeDisplayed = (!isHomePage || isMultiPane) && isBigEnough;
ViewModel.ShouldPreviewPaneBeActive = UserSettingsService.InfoPaneSettingsService.IsEnabled && ViewModel.ShouldPreviewPaneBeDisplayed;
ViewModel.ShouldViewControlBeDisplayed = SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false;

UpdatePositioning();
}
catch (Exception ex)
{
// Handle exception in case WinUI Windows is closed
// (see https://github.com/files-community/Files/issues/15599)

ViewModel.ShouldPreviewPaneBeDisplayed = (!isHomePage || isMultiPane) && isBigEnough;
ViewModel.ShouldPreviewPaneBeActive = UserSettingsService.InfoPaneSettingsService.IsEnabled && ViewModel.ShouldPreviewPaneBeDisplayed;
ViewModel.ShouldViewControlBeDisplayed = SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false;
SentrySdk.CaptureException(ex, scope =>
{
scope.User.Id = generalSettingsService.UserId;
scope.Level = SentryLevel.Warning;
});

UpdatePositioning();
App.Logger.LogWarning(ex, ex.Message);
}
}

private async void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down