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
4 changes: 0 additions & 4 deletions Files/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
LibraryManager?.Dispose();
DrivesManager?.Dispose();
deferral.Complete();

#if DEBUG
Current.Exit();
#endif
}

public static void SaveSessionTabs() // Enumerates through all tabs and gets the Path property and saves it to AppSettings.LastSessionPages
Expand Down
36 changes: 24 additions & 12 deletions Files/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
using Windows.Storage;
using Windows.Storage.FileProperties;
using Windows.Storage.Search;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
Expand Down Expand Up @@ -65,7 +64,23 @@ public class ItemViewModel : INotifyPropertyChanged, IDisposable

private IFileListCache fileListCache = FileListCacheController.GetInstance();

private NamedPipeAsAppServiceConnection Connection;
private NamedPipeAsAppServiceConnection connection;
private NamedPipeAsAppServiceConnection Connection
{
get => connection;
set
{
if (connection != null)
{
connection.RequestReceived -= Connection_RequestReceived;
}
connection = value;
if (connection != null)
{
connection.RequestReceived += Connection_RequestReceived;
}
}
}

public string WorkingDirectory
{
Expand Down Expand Up @@ -319,19 +334,13 @@ public ItemViewModel(FolderSettingsViewModel folderSettingsViewModel)
semaphoreCTS = new CancellationTokenSource();
loadPropsCTS = new CancellationTokenSource();
shouldDisplayFileExtensions = App.AppSettings.ShowFileExtensions;

AppServiceConnectionHelper.ConnectionChanged += AppServiceConnectionHelper_ConnectionChanged;
}

public void OnAppServiceConnectionChanged(NamedPipeAsAppServiceConnection connection)
private async void AppServiceConnectionHelper_ConnectionChanged(object sender, Task<NamedPipeAsAppServiceConnection> e)
{
if (Connection != null)
{
Connection.RequestReceived -= Connection_RequestReceived;
}
Connection = connection;
if (Connection != null)
{
Connection.RequestReceived += Connection_RequestReceived;
}
Connection = await e;
}

private async void Connection_RequestReceived(object sender, Dictionary<string, object> message)
Expand Down Expand Up @@ -950,6 +959,8 @@ private async void RapidAddItemsToCollectionAsync(string path, string previousDi

ItemLoadStatusChanged?.Invoke(this, new ItemLoadStatusChangedEventArgs() { Status = ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress });

Connection ??= await AppServiceConnectionHelper.Instance;

if (path.ToLower().EndsWith(ShellLibraryItem.EXTENSION))
{
if (App.LibraryManager.TryGetLibrary(path, out LibraryLocationItem library) && !library.IsEmpty)
Expand Down Expand Up @@ -1827,6 +1838,7 @@ public void Dispose()
{
Connection.RequestReceived -= Connection_RequestReceived;
}
AppServiceConnectionHelper.ConnectionChanged -= AppServiceConnectionHelper_ConnectionChanged;
}
}

Expand Down
5 changes: 1 addition & 4 deletions Files/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated;
OnNavigationParamsChanged();
ServiceConnection = await AppServiceConnectionHelper.Instance;
FilesystemViewModel.OnAppServiceConnectionChanged(ServiceConnection);
this.Loaded -= Page_Loaded;
}

Expand Down Expand Up @@ -805,7 +804,6 @@ public void Dispose()
private async void AppServiceConnectionHelper_ConnectionChanged(object sender, Task<NamedPipeAsAppServiceConnection> e)
{
ServiceConnection = await e;
FilesystemViewModel?.OnAppServiceConnectionChanged(ServiceConnection);
}

private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs e)
Expand Down Expand Up @@ -875,11 +873,10 @@ private void SetLoadingIndicatorForTabs(bool isLoading)

foreach (var x in multitaskingControls)
{
x.SetLoadingIndicatorStatus(x.Items.First(x => x.Control == tabItemControl), isLoading);
x.SetLoadingIndicatorStatus(x.Items.FirstOrDefault(x => x.Control == tabItemControl), isLoading);
}
}


public DataPackageOperation TabItemDragOver(object sender, DragEventArgs e)
{
if (e.DataView.AvailableFormats.Contains(StandardDataFormats.StorageItems))
Expand Down
4 changes: 1 addition & 3 deletions Files/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated;
OnNavigationParamsChanged();
ServiceConnection = await AppServiceConnectionHelper.Instance;
FilesystemViewModel.OnAppServiceConnectionChanged(ServiceConnection);
this.Loaded -= Page_Loaded;
}

Expand Down Expand Up @@ -942,7 +941,6 @@ public void Dispose()
private async void AppServiceConnectionHelper_ConnectionChanged(object sender, Task<NamedPipeAsAppServiceConnection> e)
{
ServiceConnection = await e;
FilesystemViewModel?.OnAppServiceConnectionChanged(ServiceConnection);
}

private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs e)
Expand Down Expand Up @@ -1012,7 +1010,7 @@ private void SetLoadingIndicatorForTabs(bool isLoading)

foreach (var x in multitaskingControls)
{
x.SetLoadingIndicatorStatus(x.Items.First(x => x.Control == tabItemControl), isLoading);
x.SetLoadingIndicatorStatus(x.Items.FirstOrDefault(x => x.Control == tabItemControl), isLoading);
}
}

Expand Down