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

Feature: Auto restore tabs if the app crashes #12005

Merged
merged 11 commits into from
Apr 16, 2023
18 changes: 15 additions & 3 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.System;
using Windows.UI.Notifications;

namespace Files.App
Expand Down Expand Up @@ -448,19 +449,30 @@ private static void AppUnhandledException(Exception ex, bool shouldShowNotificat
{
Buttons =
{
new ToastButton("ExceptionNotificationReportButton".GetLocalizedResource(), "report")
new ToastButton("ExceptionNotificationReportButton".GetLocalizedResource(), Constants.GitHub.BugReportUrl)
{
ActivationType = ToastActivationType.Foreground
ActivationType = ToastActivationType.Protocol
}
}
}
},
ActivationType = ToastActivationType.Protocol
};

// Create the toast notification
var toastNotif = new ToastNotification(toastContent.GetXml());

// And send the notification
ToastNotificationManager.CreateToastNotifier().Show(toastNotif);

// Restart the app
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
QuaintMako marked this conversation as resolved.
Show resolved Hide resolved
userSettingsService.AppSettingsService.RestoreTabsOnStartup = true;
SaveSessionTabs();
Window.DispatcherQueue.EnqueueAsync(async () =>
{
await Launcher.LaunchUriAsync(new Uri("files-uwp:"));
}).Wait(1000);
Process.GetCurrentProcess().Kill();
}

public static void CloseApp()
Expand Down
4 changes: 0 additions & 4 deletions src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ public async Task InitializeApplication(object activatedEventArgs)
break;

case IToastNotificationActivatedEventArgs eventArgsForNotification:
if (eventArgsForNotification.Argument == "report")
{
await Windows.System.Launcher.LaunchUriAsync(new Uri(Constants.GitHub.BugReportUrl));
}
break;
hishitetsu marked this conversation as resolved.
Show resolved Hide resolved

case IStartupTaskActivatedEventArgs:
Expand Down