move warning to appear on launch, not install start

This commit is contained in:
IsWaffle 2023-08-23 22:45:41 -04:00
parent 6dd92e540d
commit b8bec3c3c8
2 changed files with 24 additions and 13 deletions

View File

@ -113,11 +113,11 @@ public static class FileHelper
public static bool CheckPathForProblemLocations(string path) public static bool CheckPathForProblemLocations(string path)
{ {
if (path.EndsWith("Desktop")) return false; if (path.ToLower().EndsWith("desktop")) return true;
var problemNames = new string[] {"OneDrive", "NextCloud", "DropBox", "Google" }; var problemNames = new string[] {"onedrive", "nextcloud", "dropbox", "google" };
return problemNames.Where(x => path.Contains(x)).Count() > 0; return problemNames.Where(x => path.ToLower().Contains(x)).Count() > 0;
} }
} }

View File

@ -2,6 +2,7 @@
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using Avalonia.Threading;
using DialogHostAvalonia; using DialogHostAvalonia;
using ReactiveUI; using ReactiveUI;
using Serilog; using Serilog;
@ -71,18 +72,28 @@ public class PreChecksViewModel : ViewModelBase
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}"); Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
StartInstallCommand = ReactiveCommand.Create(async () => Task.Run(async () =>
{ {
if (FileHelper.CheckPathForProblemLocations(InstallPath)) if (FileHelper.CheckPathForProblemLocations(InstallPath))
{ {
var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing to your desktop or a cloud synced folder.\nYou might want to considering installing somewhere else to avoid issues.\n\nAre you sure you want to install to this path?\n{InstallPath}")); await Dispatcher.UIThread.InvokeAsync(async () =>
{
Log.Warning("Problem folder detected, confirming install path ...");
var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing to your desktop or a cloud synced folder.\nYou might want to consider installing somewhere else to avoid issues.\n\nAre you sure you want to install to this path?\n{InstallPath}"));
if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm) if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm)
{ {
return; Log.Information("User declined install path, exiting");
} Environment.Exit(0);
} }
});
Log.Information("User accepted install path");
}
});
StartInstallCommand = ReactiveCommand.Create(async () =>
{
UpdateInfo.ShowCard = false; UpdateInfo.ShowCard = false;
NavigateTo(new InstallViewModel(HostScreen)); NavigateTo(new InstallViewModel(HostScreen));
}); });