From 55f88a71493251f9fabf82c4641588ccfef6a8bf Mon Sep 17 00:00:00 2001 From: Nikhil Narayana Date: Sun, 15 Sep 2024 18:01:39 -0700 Subject: [PATCH] refactor: remove desktop app migration its been a few years now so we should be good to remove it --- src/dolphin/api.ts | 5 - src/dolphin/ipc.ts | 6 - src/dolphin/setup.ts | 29 +-- src/dolphin/types.ts | 1 - src/main/api.ts | 4 - src/main/ipc.ts | 2 - src/main/setup.ts | 9 - src/renderer/lib/hooks/use_app.ts | 14 -- src/renderer/lib/hooks/use_quick_start.ts | 30 ---- .../pages/quick_start/quick_start.tsx | 3 - .../steps/import_dolphin_settings_step.tsx | 167 ------------------ .../services/dolphin/dolphin.service.mock.ts | 5 - 12 files changed, 2 insertions(+), 273 deletions(-) delete mode 100644 src/renderer/pages/quick_start/steps/import_dolphin_settings_step.tsx diff --git a/src/dolphin/api.ts b/src/dolphin/api.ts index da9426311..649c89120 100644 --- a/src/dolphin/api.ts +++ b/src/dolphin/api.ts @@ -2,7 +2,6 @@ import type { GeckoCode } from "./config/gecko_code"; import { - ipc_checkDesktopAppDolphin, ipc_checkPlayKeyExists, ipc_configureDolphin, ipc_dolphinEvent, @@ -59,10 +58,6 @@ const dolphinApi: DolphinService = { async launchNetplayDolphin(options: { bootToCss?: boolean }): Promise { await ipc_launchNetplayDolphin.renderer!.trigger(options); }, - async checkDesktopAppDolphin() { - const { result } = await ipc_checkDesktopAppDolphin.renderer!.trigger({}); - return result; - }, async importDolphinSettings(options: { toImportDolphinPath: string; dolphinType: DolphinLaunchType }): Promise { await ipc_importDolphinSettings.renderer!.trigger(options); }, diff --git a/src/dolphin/ipc.ts b/src/dolphin/ipc.ts index b1056002f..aa975978d 100644 --- a/src/dolphin/ipc.ts +++ b/src/dolphin/ipc.ts @@ -54,12 +54,6 @@ export const ipc_launchNetplayDolphin = makeEndpoint.main( _, ); -export const ipc_checkDesktopAppDolphin = makeEndpoint.main( - "getDesktopAppDolphinPath", - _, - <{ dolphinPath: string; exists: boolean }>_, -); - // toImportDolphin path must point to a "Slippi Dolphin.{exe,app}" export const ipc_importDolphinSettings = makeEndpoint.main( "importDolphinSettings", diff --git a/src/dolphin/setup.ts b/src/dolphin/setup.ts index 5b517cf43..81436d281 100644 --- a/src/dolphin/setup.ts +++ b/src/dolphin/setup.ts @@ -1,4 +1,4 @@ -import { app, shell } from "electron"; +import { shell } from "electron"; import log from "electron-log"; import * as fs from "fs-extra"; import isEqual from "lodash/isEqual"; @@ -6,7 +6,6 @@ import path from "path"; import { fileExists } from "utils/file_exists"; import { - ipc_checkDesktopAppDolphin, ipc_checkPlayKeyExists, ipc_configureDolphin, ipc_dolphinEvent, @@ -25,10 +24,9 @@ import { import type { DolphinManager } from "./manager"; import { deletePlayKeyFile, writePlayKeyFile } from "./playkey"; import { DolphinLaunchType } from "./types"; -import { fetchGeckoCodes, findDolphinExecutable, saveGeckoCodes, updateBootToCssCode } from "./util"; +import { fetchGeckoCodes, saveGeckoCodes, updateBootToCssCode } from "./util"; const isMac = process.platform === "darwin"; -const isLinux = process.platform === "linux"; export default function setupDolphinIpc({ dolphinManager }: { dolphinManager: DolphinManager }) { dolphinManager.events.subscribe((event) => { @@ -131,29 +129,6 @@ export default function setupDolphinIpc({ dolphinManager }: { dolphinManager: Do return { success: true }; }); - ipc_checkDesktopAppDolphin.main!.handle(async () => { - // get the path and check existence - const desktopAppPath = path.join(app.getPath("appData"), "Slippi Desktop App"); - let exists = await fs.pathExists(desktopAppPath); - - if (!exists) { - return { dolphinPath: "", exists: false }; - } - - // Linux doesn't need to do anything because their dolphin settings are in a user config dir - if (isLinux && exists) { - await fs.remove(desktopAppPath); - return { dolphinPath: "", exists: false }; - } - - const dolphinFolderPath = path.join(desktopAppPath, "dolphin"); - exists = await fs.pathExists(dolphinFolderPath); - - const dolphinExecutablePath = await findDolphinExecutable(DolphinLaunchType.NETPLAY, dolphinFolderPath); - - return { dolphinPath: dolphinExecutablePath, exists: exists }; - }); - ipc_fetchGeckoCodes.main!.handle(async ({ dolphinType }) => { const installation = dolphinManager.getInstallation(dolphinType); const codes = await fetchGeckoCodes(installation); diff --git a/src/dolphin/types.ts b/src/dolphin/types.ts index 0a8244da1..b42259292 100644 --- a/src/dolphin/types.ts +++ b/src/dolphin/types.ts @@ -111,7 +111,6 @@ export interface DolphinService { removePlayKeyFile(): Promise; viewSlpReplay(files: ReplayQueueItem[]): Promise; launchNetplayDolphin(options: { bootToCss?: boolean }): Promise; - checkDesktopAppDolphin(): Promise<{ dolphinPath: string; exists: boolean }>; importDolphinSettings(options: { toImportDolphinPath: string; dolphinType: DolphinLaunchType }): Promise; fetchGeckoCodes(dolphinLaunchType: DolphinLaunchType): Promise; saveGeckoCodes(dolphinLaunchType: DolphinLaunchType, geckoCodes: GeckoCode[]): Promise; diff --git a/src/main/api.ts b/src/main/api.ts index a24143c10..be12ee6f5 100644 --- a/src/main/api.ts +++ b/src/main/api.ts @@ -5,7 +5,6 @@ import { ipc_checkValidIso, ipc_clearTempFolder, ipc_copyLogsToClipboard, - ipc_deleteDesktopAppPath, ipc_deleteFiles, ipc_fetchNewsFeed, ipc_getLatestGitHubReleaseVersion, @@ -35,9 +34,6 @@ export default { async deleteFiles(filePaths: string[]) { await ipc_deleteFiles.renderer!.trigger({ filePaths }); }, - async deleteDesktopAppPath() { - await ipc_deleteDesktopAppPath.renderer!.trigger({}); - }, async copyLogsToClipboard(): Promise { await ipc_copyLogsToClipboard.renderer!.trigger({}); }, diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 26b78ca6d..f4377407c 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -10,8 +10,6 @@ export const ipc_checkValidIso = makeEndpoint.main( <{ path: string; valid: IsoValidity }>_, ); -export const ipc_deleteDesktopAppPath = makeEndpoint.main("deleteDesktopAppPath", _, _); - export const ipc_copyLogsToClipboard = makeEndpoint.main("copyLogsToClipboard", _, _); export const ipc_checkForUpdate = makeEndpoint.main("checkForUpdate", _, _); diff --git a/src/main/setup.ts b/src/main/setup.ts index c570b6d82..e7abe993c 100644 --- a/src/main/setup.ts +++ b/src/main/setup.ts @@ -18,7 +18,6 @@ import { ipc_checkValidIso, ipc_clearTempFolder, ipc_copyLogsToClipboard, - ipc_deleteDesktopAppPath, ipc_deleteFiles, ipc_fetchNewsFeed, ipc_getLatestGitHubReleaseVersion, @@ -90,14 +89,6 @@ export default function setupMainIpc({ } }); - ipc_deleteDesktopAppPath.main!.handle(async () => { - // get the path and remove - const desktopAppPath = path.join(app.getPath("appData"), "Slippi Desktop App"); - await fs.remove(desktopAppPath); - - return { success: true }; - }); - ipc_copyLogsToClipboard.main!.handle(async () => { let logsFolder = isMac ? app.getPath("logs") : path.resolve(app.getPath("userData"), "logs"); if (isDevelopment) { diff --git a/src/renderer/lib/hooks/use_app.ts b/src/renderer/lib/hooks/use_app.ts index 4e4ce962b..18ab2e267 100644 --- a/src/renderer/lib/hooks/use_app.ts +++ b/src/renderer/lib/hooks/use_app.ts @@ -8,8 +8,6 @@ import { useToasts } from "@/lib/hooks/use_toasts"; import { useServices } from "@/services"; import type { AuthUser } from "@/services/auth/types"; -import { useDesktopApp } from "./use_quick_start"; - export const useAppStore = create( combine( { @@ -39,8 +37,6 @@ export const useAppInitialization = () => { const setUserData = useAccount((store) => store.setUserData); const setUser = useAccount((store) => store.setUser); const setServerError = useAccount((store) => store.setServerError); - const setDesktopAppExists = useDesktopApp((store) => store.setExists); - const setDesktopAppDolphinPath = useDesktopApp((store) => store.setDolphinPath); const initialize = async () => { if (initializing || initialized) { @@ -93,16 +89,6 @@ export const useAppInitialization = () => { }); }); - promises.push( - dolphinService - .checkDesktopAppDolphin() - .then(({ exists, dolphinPath }) => { - setDesktopAppExists(exists); - setDesktopAppDolphinPath(dolphinPath); - }) - .catch(log.error), - ); - // Check if there is an update to the launcher promises.push(window.electron.common.checkForAppUpdates()); diff --git a/src/renderer/lib/hooks/use_quick_start.ts b/src/renderer/lib/hooks/use_quick_start.ts index c8b7f278e..80936e32f 100644 --- a/src/renderer/lib/hooks/use_quick_start.ts +++ b/src/renderer/lib/hooks/use_quick_start.ts @@ -1,8 +1,6 @@ import { currentRulesVersion } from "@common/constants"; import React from "react"; import { useNavigate } from "react-router-dom"; -import { create } from "zustand"; -import { combine } from "zustand/middleware"; import { useSettings } from "@/lib/hooks/use_settings"; @@ -12,7 +10,6 @@ export enum QuickStartStep { LOGIN = "LOGIN", VERIFY_EMAIL = "VERIFY_EMAIL", ACCEPT_RULES = "ACCEPT_RULES", - MIGRATE_DOLPHIN = "MIGRATE_DOLPHIN", ACTIVATE_ONLINE = "ACTIVATE_ONLINE", SET_ISO_PATH = "SET_ISO_PATH", COMPLETE = "COMPLETE", @@ -26,7 +23,6 @@ function generateSteps( showRules: boolean; serverError: boolean; hasIso: boolean; - hasOldDesktopApp: boolean; }>, ): QuickStartStep[] { // Build the steps in reverse order @@ -36,10 +32,6 @@ function generateSteps( steps.unshift(QuickStartStep.SET_ISO_PATH); } - if (options.hasOldDesktopApp) { - steps.unshift(QuickStartStep.MIGRATE_DOLPHIN); - } - if (!options.hasPlayKey && !options.serverError) { steps.unshift(QuickStartStep.ACTIVATE_ONLINE); } @@ -65,7 +57,6 @@ export const useQuickStart = () => { const user = useAccount((store) => store.user); const userData = useAccount((store) => store.userData); const serverError = useAccount((store) => store.serverError); - const desktopAppPathExists = useDesktopApp((store) => store.exists); const options = { hasUser: Boolean(user), hasIso: Boolean(savedIsoPath), @@ -73,7 +64,6 @@ export const useQuickStart = () => { hasPlayKey: Boolean(userData?.playKey), showRules: Boolean((userData?.rulesAccepted ?? 0) < currentRulesVersion), serverError: Boolean(serverError), - hasOldDesktopApp: desktopAppPathExists, }; const [steps] = React.useState(generateSteps(options)); const [currentStep, setCurrentStep] = React.useState(null); @@ -90,10 +80,6 @@ export const useQuickStart = () => { stepToShow = QuickStartStep.SET_ISO_PATH; } - if (options.hasOldDesktopApp) { - stepToShow = QuickStartStep.MIGRATE_DOLPHIN; - } - if (!options.hasPlayKey && !options.serverError) { stepToShow = QuickStartStep.ACTIVATE_ONLINE; } @@ -115,7 +101,6 @@ export const useQuickStart = () => { steps, options.hasIso, options.hasVerifiedEmail, - options.hasOldDesktopApp, options.hasPlayKey, options.hasUser, options.showRules, @@ -144,18 +129,3 @@ export const useQuickStart = () => { prevStep, }; }; - -export const oldDesktopApp = { path: "", exists: false }; - -export const useDesktopApp = create( - combine( - { - exists: false, - dolphinPath: "", - }, - (set) => ({ - setExists: (exists: boolean) => set({ exists }), - setDolphinPath: (dolphinPath: string) => set({ dolphinPath }), - }), - ), -); diff --git a/src/renderer/pages/quick_start/quick_start.tsx b/src/renderer/pages/quick_start/quick_start.tsx index 6822aca5a..c61b59c1d 100644 --- a/src/renderer/pages/quick_start/quick_start.tsx +++ b/src/renderer/pages/quick_start/quick_start.tsx @@ -11,7 +11,6 @@ import { platformTitleBarStyles } from "@/styles/platform_title_bar_styles"; import { AcceptRulesStep } from "./steps/accept_rules_step"; import { ActivateOnlineStep } from "./steps/activate_online_step"; -import { ImportDolphinSettingsStep } from "./steps/import_dolphin_settings_step"; import { IsoSelectionStep } from "./steps/iso_selection_step"; import { LoginStep } from "./steps/login_step"; import { SetupCompleteStep } from "./steps/setup_complete_step"; @@ -43,8 +42,6 @@ const getStepContent = (step: QuickStartStep | null) => { return ; case QuickStartStep.ACTIVATE_ONLINE: return ; - case QuickStartStep.MIGRATE_DOLPHIN: - return ; case QuickStartStep.SET_ISO_PATH: return ; case QuickStartStep.COMPLETE: diff --git a/src/renderer/pages/quick_start/steps/import_dolphin_settings_step.tsx b/src/renderer/pages/quick_start/steps/import_dolphin_settings_step.tsx deleted file mode 100644 index 6ca73f965..000000000 --- a/src/renderer/pages/quick_start/steps/import_dolphin_settings_step.tsx +++ /dev/null @@ -1,167 +0,0 @@ -import { DolphinLaunchType } from "@dolphin/types"; -import { css } from "@emotion/react"; -import Box from "@mui/material/Box"; -import Button from "@mui/material/Button"; -import Container from "@mui/material/Container"; -import FormHelperText from "@mui/material/FormHelperText"; -import React from "react"; -import { Controller, useForm } from "react-hook-form"; - -import { Checkbox } from "@/components/form/checkbox"; -import { PathInput } from "@/components/path_input"; -import { useDolphinActions } from "@/lib/dolphin/use_dolphin_actions"; -import { useDesktopApp } from "@/lib/hooks/use_quick_start"; -import { useToasts } from "@/lib/hooks/use_toasts"; -import { useServices } from "@/services"; - -import { QuickStartHeader } from "../quick_start_header/quick_start_header"; - -const isMac = window.electron.bootstrap.isMac; - -type FormValues = { - netplayPath: string; - shouldImportPlayback: boolean; - shouldImportNetplay: boolean; -}; - -export const ImportDolphinSettingsStep = React.memo(() => { - const setExists = useDesktopApp((store) => store.setExists); - const desktopAppDolphinPath = useDesktopApp((store) => store.dolphinPath); - const { showError } = useToasts(); - const { dolphinService } = useServices(); - const { importDolphin } = useDolphinActions(dolphinService); - - const migrateDolphin = async (values: FormValues) => { - if (values.shouldImportNetplay) { - importDolphin(values.netplayPath, DolphinLaunchType.NETPLAY); - } - if (values.shouldImportPlayback) { - importDolphin(desktopAppDolphinPath, DolphinLaunchType.PLAYBACK); - } - - await finishMigration(); - }; - - const finishMigration = async () => { - // delete desktop app path - await window.electron.common.deleteDesktopAppPath(); - setExists(false); - }; - - const { - handleSubmit, - watch, - control, - setValue, - formState: { errors }, - } = useForm({ - defaultValues: { netplayPath: "", shouldImportNetplay: false, shouldImportPlayback: false }, - }); - const netplayPath = watch("netplayPath"); - const migrateNetplay = watch("shouldImportNetplay"); - const migratePlayback = watch("shouldImportPlayback"); - - const onFormSubmit = handleSubmit((values) => { - migrateDolphin(values).catch(showError); - }); - - const extension = isMac ? "app" : "exe"; - return ( - - - Import old Dolphin settings -
Which Dolphin settings would you like to import?
- -
* { - margin-top: 5px; - } - `} - > - setValue("shouldImportPlayback", !migratePlayback)} - /> - setValue("shouldImportNetplay", !migrateNetplay)} - /> -
-
-
- {migrateNetplay && ( -
-
- Select the Dolphin.{extension} with the desired netplay settings. -
- ( - setValue("netplayPath", newPath)} - placeholder="No Netplay Dolphin selected" - options={{ - filters: [{ name: "Slippi Dolphin", extensions: [isMac ? "app" : "exe"] }], - }} - /> - )} - rules={{ validate: (val) => val.length > 0 || "No path selected" }} - /> -
- {errors?.netplayPath?.message} -
-
- )} - -
- - -
-
-
-
-
- ); -}); diff --git a/src/renderer/services/dolphin/dolphin.service.mock.ts b/src/renderer/services/dolphin/dolphin.service.mock.ts index 5abec8139..9fd5a2675 100644 --- a/src/renderer/services/dolphin/dolphin.service.mock.ts +++ b/src/renderer/services/dolphin/dolphin.service.mock.ts @@ -85,11 +85,6 @@ class MockDolphinClient implements DolphinService { throw new Error("Method not implemented."); } - @delayAndMaybeError(SHOULD_ERROR) - public async checkDesktopAppDolphin(): Promise<{ dolphinPath: string; exists: boolean }> { - throw new Error("Method not implemented."); - } - @delayAndMaybeError(SHOULD_ERROR) public async importDolphinSettings(_options: { toImportDolphinPath: string;