Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed Feb 27, 2024
1 parent e3ec955 commit 56dd2d4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private async void Window_Closed(object sender, WindowEventArgs args)
return;
}

// Save the current tab list in case it was overwriten by another instance
AppLifecycleHelper.SaveSessionTabs();

// Continue running the app on the background
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti
// Please check "Output Window" for exception details (View -> Output Window) (CTRL + ALT + O)
Debugger.Break();

// Save the current tab list in case it was overwriten by another instance
SaveSessionTabs();
App.Logger.LogError(ex, ex?.Message ?? "An unhandled error occurred.");

Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Helpers/Navigation/NavigationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static async Task AddNewTabByPathAsync(Type type, string? path, int atInd

App.AppModel.TabStripSelectedIndex = index;

// Save the updated tab list
AppLifecycleHelper.SaveSessionTabs();
}

Expand Down Expand Up @@ -89,6 +90,7 @@ public static async Task AddNewTabByParamAsync(Type type, object tabViewItemArgs
MainPageViewModel.AppInstances.Insert(index, tabItem);
App.AppModel.TabStripSelectedIndex = index;

// Save the updated tab list
AppLifecycleHelper.SaveSessionTabs();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ public async Task CheckForUpdatesAsync()

private async Task DownloadAndInstallAsync()
{
// Save the updated tab list before installing the update
AppLifecycleHelper.SaveSessionTabs();

App.AppModel.ForceProcessTermination = true;

var downloadOperation = _storeContext?.RequestDownloadAndInstallStorePackageUpdatesAsync(_updatePackages);
var result = await downloadOperation.AsTask();

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/TabBar/BaseTabBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void CloseTab(TabBarItem tabItem)
tabItem.NavigationParameter,
});


// Save the updated tab list
AppLifecycleHelper.SaveSessionTabs();

if (Items.Count == 0)
Expand Down
15 changes: 11 additions & 4 deletions src/Files.App/ViewModels/Settings/GeneralViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ public GeneralViewModel()

private async void DoRestartAsync()
{
UserSettingsService.AppSettingsService.RestoreTabsOnStartup = true; // Tells the app to restore tabs when it's next launched
AppLifecycleHelper.SaveSessionTabs(); // Saves the open tabs
await Launcher.LaunchUriAsync(new Uri("files-uwp:")); // Launches a new instance of Files
Process.GetCurrentProcess().Kill(); // Closes the current instance
// Tells the app to restore tabs when it's next launched
UserSettingsService.AppSettingsService.RestoreTabsOnStartup = true;

// Save the updated tab list before restarting
AppLifecycleHelper.SaveSessionTabs();

// Launches a new instance of Files
await Launcher.LaunchUriAsync(new Uri("files-uwp:"));

// Closes the current instance
Process.GetCurrentProcess().Kill();
}

private void DoCancelRestart()
Expand Down

0 comments on commit 56dd2d4

Please sign in to comment.