[bugfix-821] Add error messages for Beat Saber uninstallation

This commit is contained in:
Zagrios
2025-03-22 20:29:20 +01:00
parent 011e9d1b04
commit 4435df2fd7
18 changed files with 158 additions and 16 deletions
@@ -306,14 +306,12 @@ export class BSLocalVersionService {
return versions;
}
public async deleteVersion(version: BSVersion): Promise<boolean>{
if(version.steam || version.oculus){ return false; }
public async deleteVersion(version: BSVersion): Promise<void>{
if(version.steam || version.oculus){ throw new CustomError("BSManager is not able to delete official Beat Saber versions", "CantDeleteOfficialVersion"); }
const versionFolder = await this.getVersionPath(version);
if(!(await pathExists(versionFolder))){ return true; }
if(!(await pathExists(versionFolder))){ throw new CustomError("Version not found", "VersionNotFound"); }
return deleteFolder(versionFolder)
.then(() => { return true; })
.catch(() => { return false; })
return deleteFolder(versionFolder);
}
public async editVersion(version: BSVersion, name: string, color: string): Promise<BSVersion>{
@@ -16,6 +16,7 @@ import equal from "fast-deep-equal";
import { useOnUpdate } from "renderer/hooks/use-on-update.hook";
import { BsDownloaderService } from "renderer/services/bs-version-download/bs-downloader.service";
import { ProgressBarService } from "renderer/services/progress-bar.service";
import { noop } from "shared/helpers/function.helpers";
export function BsVersionItem(props: { version: BSVersion }) {
@@ -70,7 +71,7 @@ export function BsVersionItem(props: { version: BSVersion }) {
const wasVerification = bsDownloader.isVerifying;
bsDownloader.stopDownload().then(() => {
if(wasVerification){ return; }
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
bsUninstallerService.uninstall(versionDownload).then(() => verionManagerService.askInstalledVersions()).catch(noop);
});
};
@@ -28,6 +28,7 @@ import { logRenderError } from "renderer";
import { BsModsManagerService } from "renderer/services/bs-mods-manager.service";
import { noop } from "shared/helpers/function.helpers";
import { useTranslationV2 } from "renderer/hooks/use-translation.hook";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export function VersionViewer() {
@@ -125,13 +126,25 @@ export function VersionViewer() {
const uninstall = async () => {
const modalCompleted = await modalService.openModal(UninstallModal, { data: state });
if (modalCompleted.exitCode === ModalExitCode.COMPLETED) {
bsUninstallerService.uninstall(state).then(() => {
bsVersionManagerService.askInstalledVersions().then(versions => {
navigateToVersion(versions?.at(0));
});
});
if (modalCompleted.exitCode !== ModalExitCode.COMPLETED) {
return;
}
bsUninstallerService.uninstall(state).then(() => {
bsVersionManagerService.askInstalledVersions().then(versions => {
navigateToVersion(versions?.at(0));
});
}).catch((err: CustomError) => {
let desc = err?.message;
if (["CantDeleteOfficialVersion", "VersionNotFound"].includes(err?.code)) {
desc = `notifications.bs-uninstall.errors.desc.${err.code}`;
} else if (err?.code?.startsWith("generic.fs.delete-folder")) {
desc = "notifications.bs-uninstall.errors.desc.delete-folder";
}
notification.notifyError({ title: "notifications.bs-uninstall.errors.title", desc });
});
};
const edit = () => {
@@ -18,7 +18,7 @@ export class BSUninstallerService {
this.ipcService = IpcService.getInstance();
}
public uninstall(version: BSVersion): Promise<boolean> {
return lastValueFrom(this.ipcService.sendV2("bs.uninstall", version)).catch(() => false);
public uninstall(version: BSVersion): Promise<void> {
return lastValueFrom(this.ipcService.sendV2("bs.uninstall", version));
}
}
+1 -1
View File
@@ -103,7 +103,7 @@ export interface IpcChannelMapping {
"install-playlist-file": {request: {bplist: BPList, version?: BSVersion, dest?: string}, response: LocalBPListsDetails};
/* ** bs-uninstall-ipcs ** */
"bs.uninstall": { request: BSVersion, response: boolean };
"bs.uninstall": { request: BSVersion, response: void };
/* ** bs-version-ipcs ** */
"bs-version.get-version-dict": { request: void, response: BSVersion[] };