Skip to content

Commit

Permalink
refactor: remove desktop app migration
Browse files Browse the repository at this point in the history
its been a few years now so we should be good to remove it
  • Loading branch information
NikhilNarayana committed Sep 16, 2024
1 parent 0560dda commit 55f88a7
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 273 deletions.
5 changes: 0 additions & 5 deletions src/dolphin/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import type { GeckoCode } from "./config/gecko_code";
import {
ipc_checkDesktopAppDolphin,
ipc_checkPlayKeyExists,
ipc_configureDolphin,
ipc_dolphinEvent,
Expand Down Expand Up @@ -59,10 +58,6 @@ const dolphinApi: DolphinService = {
async launchNetplayDolphin(options: { bootToCss?: boolean }): Promise<void> {
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<void> {
await ipc_importDolphinSettings.renderer!.trigger(options);
},
Expand Down
6 changes: 0 additions & 6 deletions src/dolphin/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ export const ipc_launchNetplayDolphin = makeEndpoint.main(
<SuccessPayload>_,
);

export const ipc_checkDesktopAppDolphin = makeEndpoint.main(
"getDesktopAppDolphinPath",
<EmptyPayload>_,
<{ dolphinPath: string; exists: boolean }>_,
);

// toImportDolphin path must point to a "Slippi Dolphin.{exe,app}"
export const ipc_importDolphinSettings = makeEndpoint.main(
"importDolphinSettings",
Expand Down
29 changes: 2 additions & 27 deletions src/dolphin/setup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
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";
import path from "path";
import { fileExists } from "utils/file_exists";

import {
ipc_checkDesktopAppDolphin,
ipc_checkPlayKeyExists,
ipc_configureDolphin,
ipc_dolphinEvent,
Expand All @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/dolphin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export interface DolphinService {
removePlayKeyFile(): Promise<void>;
viewSlpReplay(files: ReplayQueueItem[]): Promise<void>;
launchNetplayDolphin(options: { bootToCss?: boolean }): Promise<void>;
checkDesktopAppDolphin(): Promise<{ dolphinPath: string; exists: boolean }>;
importDolphinSettings(options: { toImportDolphinPath: string; dolphinType: DolphinLaunchType }): Promise<void>;
fetchGeckoCodes(dolphinLaunchType: DolphinLaunchType): Promise<GeckoCode[]>;
saveGeckoCodes(dolphinLaunchType: DolphinLaunchType, geckoCodes: GeckoCode[]): Promise<void>;
Expand Down
4 changes: 0 additions & 4 deletions src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ipc_checkValidIso,
ipc_clearTempFolder,
ipc_copyLogsToClipboard,
ipc_deleteDesktopAppPath,
ipc_deleteFiles,
ipc_fetchNewsFeed,
ipc_getLatestGitHubReleaseVersion,
Expand Down Expand Up @@ -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<void> {
await ipc_copyLogsToClipboard.renderer!.trigger({});
},
Expand Down
2 changes: 0 additions & 2 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const ipc_checkValidIso = makeEndpoint.main(
<{ path: string; valid: IsoValidity }>_,
);

export const ipc_deleteDesktopAppPath = makeEndpoint.main("deleteDesktopAppPath", <EmptyPayload>_, <SuccessPayload>_);

export const ipc_copyLogsToClipboard = makeEndpoint.main("copyLogsToClipboard", <EmptyPayload>_, <SuccessPayload>_);

export const ipc_checkForUpdate = makeEndpoint.main("checkForUpdate", <EmptyPayload>_, <SuccessPayload>_);
Expand Down
9 changes: 0 additions & 9 deletions src/main/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
ipc_checkValidIso,
ipc_clearTempFolder,
ipc_copyLogsToClipboard,
ipc_deleteDesktopAppPath,
ipc_deleteFiles,
ipc_fetchNewsFeed,
ipc_getLatestGitHubReleaseVersion,
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 0 additions & 14 deletions src/renderer/lib/hooks/use_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());

Expand Down
30 changes: 0 additions & 30 deletions src/renderer/lib/hooks/use_quick_start.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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",
Expand All @@ -26,7 +23,6 @@ function generateSteps(
showRules: boolean;
serverError: boolean;
hasIso: boolean;
hasOldDesktopApp: boolean;
}>,
): QuickStartStep[] {
// Build the steps in reverse order
Expand All @@ -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);
}
Expand All @@ -65,15 +57,13 @@ 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),
hasVerifiedEmail: Boolean(user?.emailVerified),
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<QuickStartStep | null>(null);
Expand All @@ -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;
}
Expand All @@ -115,7 +101,6 @@ export const useQuickStart = () => {
steps,
options.hasIso,
options.hasVerifiedEmail,
options.hasOldDesktopApp,
options.hasPlayKey,
options.hasUser,
options.showRules,
Expand Down Expand Up @@ -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 }),
}),
),
);
3 changes: 0 additions & 3 deletions src/renderer/pages/quick_start/quick_start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -43,8 +42,6 @@ const getStepContent = (step: QuickStartStep | null) => {
return <AcceptRulesStep />;
case QuickStartStep.ACTIVATE_ONLINE:
return <ActivateOnlineStep />;
case QuickStartStep.MIGRATE_DOLPHIN:
return <ImportDolphinSettingsStep />;
case QuickStartStep.SET_ISO_PATH:
return <IsoSelectionStep />;
case QuickStartStep.COMPLETE:
Expand Down
Loading

0 comments on commit 55f88a7

Please sign in to comment.