diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e126d31..eeaa1c3 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -220,6 +220,26 @@ fn get_launch_argument() -> Option { return launch_arg.to_owned(); } + #[tauri::command(async)] +fn clean_up_old_install(yarg_folder: String, setlist_folder: String) -> Result<(), String> { + let mut stable_old = PathBuf::from(&yarg_folder); + stable_old.push("stable"); + clear_folder(&stable_old)?; + let _ = fs::remove_dir(&stable_old); + + let mut nightly_old = PathBuf::from(&yarg_folder); + nightly_old.push("nightly"); + clear_folder(&nightly_old)?; + let _ = fs::remove_dir(&nightly_old); + + let mut setlist_old = PathBuf::from(&setlist_folder); + setlist_old.push("official"); + clear_folder(&setlist_old)?; + let _ = fs::remove_dir(&setlist_old); + + Ok(()) +} + fn main() { let args = CommandLineArgs::parse(); @@ -242,7 +262,9 @@ fn main() { launch_profile, open_folder_profile, - get_launch_argument + get_launch_argument, + + clean_up_old_install ]) .setup(|app| { // Show the window's shadow diff --git a/src/components/Onboarding/Onboarding.module.css b/src/components/Onboarding/Onboarding.module.css index 8b0a5b4..4af8a1b 100644 --- a/src/components/Onboarding/Onboarding.module.css +++ b/src/components/Onboarding/Onboarding.module.css @@ -161,7 +161,7 @@ align-self: stretch; } -.offline { +.center { height: 100%; display: flex; diff --git a/src/components/Onboarding/index.tsx b/src/components/Onboarding/index.tsx index fc1a96e..4a2f4d3 100644 --- a/src/components/Onboarding/index.tsx +++ b/src/components/Onboarding/index.tsx @@ -42,7 +42,7 @@ const Onboarding: React.FC = (props: Props) => { if (offlineStatus.isOffline) { return
-
+
You're offline! Please connect to the internet and restart the launcher to finish the launcher onboarding process. @@ -75,6 +75,16 @@ const Onboarding: React.FC = (props: Props) => { await directories.setDirs(downloadLocation); directories = useDirectories.getState(); + // If the user has old stuff installed, remove those + try { + await invoke("clean_up_old_install", { + yargFolder: directories.customDirs?.yargFolder, + setlistFolder: directories.customDirs?.setlistFolder + }); + } catch { + // Ignore + } + for (const url of profileUrls) { const uuid = await useProfileStore.getState().activateProfile(url); if (uuid === undefined) { @@ -94,8 +104,8 @@ const Onboarding: React.FC = (props: Props) => { } return
-
- {!loading && <> + {!loading && +
@@ -136,8 +146,15 @@ const Onboarding: React.FC = (props: Props) => {
- } -
+
+ } + {loading && +
+ + Loading, please wait... + +
+ }
; };