fix(content): changing mod versions works again
This commit is contained in:
@@ -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<void>;
|
||||
reinstall: (
|
||||
contentType: ContentType,
|
||||
oldVersionId: string,
|
||||
projectId: string,
|
||||
newVersionId: string,
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
type BackupFunctions = {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user