From d7c0d1196f8c1850fd7ccbc1644941c6db4dc306 Mon Sep 17 00:00:00 2001 From: Evan Song Date: Mon, 3 Feb 2025 09:38:50 -0700 Subject: [PATCH] fix(content): changing mod versions works again --- apps/frontend/src/composables/pyroServers.ts | 25 +++++++++++-------- .../servers/manage/[id]/content/index.vue | 9 ++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/frontend/src/composables/pyroServers.ts b/apps/frontend/src/composables/pyroServers.ts index 74f76e3a5..5cb59f5d3 100644 --- a/apps/frontend/src/composables/pyroServers.ts +++ b/apps/frontend/src/composables/pyroServers.ts @@ -546,16 +546,15 @@ const removeContent = async (contentType: ContentType, contentId: string) => { const reinstallContent = async ( contentType: ContentType, - contentId: string, - newContentId: string, + oldVersionId: string, + projectId: string, + newVersionId: string, ) => { try { - await PyroFetch(`servers/${internalServerRefrence.value.serverId}/mods/${contentId}`, { - method: "PUT", - body: { install_as: contentType, version_id: newContentId }, - }); + await removeContent(contentType, oldVersionId); + await installContent(contentType.toLowerCase() as ContentType, projectId, newVersionId); } catch (error) { - console.error("Error reinstalling mod:", error); + console.error("Error reinstalling content:", error); throw error; } }; @@ -1168,10 +1167,16 @@ type ContentFunctions = { /** * Reinstalls a mod to a server. * @param contentType - The type of content to reinstall. - * @param contentId - The ID of the content. - * @param newContentId - The ID of the new version. + * @param oldVersionId - The ID of the old version. + * @param projectId - The ID of the project. + * @param newVersionId - The ID of the new version. */ - reinstall: (contentType: ContentType, contentId: string, newContentId: string) => Promise; + reinstall: ( + contentType: ContentType, + oldVersionId: string, + projectId: string, + newVersionId: string, + ) => Promise; }; type BackupFunctions = { diff --git a/apps/frontend/src/pages/servers/manage/[id]/content/index.vue b/apps/frontend/src/pages/servers/manage/[id]/content/index.vue index 8161fa97c..7c2ff5a3d 100644 --- a/apps/frontend/src/pages/servers/manage/[id]/content/index.vue +++ b/apps/frontend/src/pages/servers/manage/[id]/content/index.vue @@ -607,12 +607,19 @@ async function changeModVersion() { modModal.value.hide(); await props.server.content?.reinstall( type.value, - currentMod.value.version_id, + `/mods/${currentMod.value.filename}`, + currentMod.value.project_id!, currentVersion.value.id, ); await props.server.refresh(["general", "content"]); } catch (error) { console.error("Error changing mod version:", error); + addNotification({ + group: "main", + title: "Failed to change mod version", + text: error instanceof Error ? error.message : "An unexpected error occurred", + type: "error", + }); } currentMod.value.changing = false; }