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

Dispose Homepage on navigation #4472

Merged
merged 5 commits into from
May 14, 2021
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
1 change: 1 addition & 0 deletions Files/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Files.Common;
using Files.Dialogs;
using Files.EventArguments;
using Files.Extensions;
using Files.Filesystem;
using Files.Filesystem.FilesystemHistory;
using Files.Filesystem.Search;
Expand Down
1 change: 1 addition & 0 deletions Files/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Files.DataModels;
using Files.Dialogs;
using Files.EventArguments;
using Files.Extensions;
using Files.Filesystem;
using Files.Filesystem.FilesystemHistory;
using Files.Filesystem.Search;
Expand Down
13 changes: 8 additions & 5 deletions Files/Views/WidgetsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace Files.Views
public sealed partial class WidgetsPage : Page, IDisposable
{
private IShellPage AppInstance = null;
public SettingsViewModel AppSettings => App.AppSettings;
public FolderSettingsViewModel FolderSettings => AppInstance?.InstanceViewModel.FolderSettings;
public NamedPipeAsAppServiceConnection Connection => AppInstance?.ServiceConnection;

private LibraryCards libraryCards;
private DrivesWidget drivesWidget;
Expand All @@ -41,6 +39,13 @@ public WidgetsPage()
Widgets.ViewModel.WidgetListRefreshRequestedInvoked += ViewModel_WidgetListRefreshRequestedInvoked;
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.Dispose();

base.OnNavigatedFrom(e);
}

public void RefreshWidgetList() => Widgets.ViewModel.RefreshWidgetList();

private void ViewModel_WidgetListRefreshRequestedInvoked(object sender, EventArgs e)
Expand Down Expand Up @@ -133,7 +138,7 @@ private async void RecentFilesWidget_RecentFileInvoked(object sender, UserContro
}
else
{
foreach (DriveItem drive in Enumerable.Concat(App.DrivesManager.Drives, AppSettings.CloudDrivesManager.Drives))
foreach (DriveItem drive in Enumerable.Concat(App.DrivesManager.Drives, App.AppSettings.CloudDrivesManager.Drives))
{
if (drive.Path.ToString() == new DirectoryInfo(e.ItemPath).Root.ToString())
{
Expand Down Expand Up @@ -232,8 +237,6 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)

#region IDisposable

// TODO: This Dispose() is never called, please implement the functionality to call this function.
// This IDisposable.Dispose() needs to be called to unhook events in BundlesWidget to avoid memory leaks.
public void Dispose()
{
ViewModel.YourHomeLoadedInvoked -= ViewModel_YourHomeLoadedInvoked;
Expand Down