refactor(patch-editor): streamline patch saving and loading logic

- Removed the local state for saving status and integrated loading state directly from the mutation hook.
- Updated the saveAsPatch function to handle success and error notifications more cleanly.
- Adjusted the file content loading to ensure it retrieves the latest data, improving user experience and consistency in the PatchEditor component.
- Refactored API calls in the patch router to unify patch retrieval logic for applications and composes, enhancing maintainability.
This commit is contained in:
Mauricio Siu
2026-02-17 00:41:46 -06:00
parent 88f387dd83
commit 20320639ce
3 changed files with 36 additions and 76 deletions
+8 -16
View File
@@ -76,23 +76,15 @@ export const findPatchesByComposeId = async (composeId: string) => {
export const findPatchByFilePath = async (
filePath: string,
applicationId?: string,
composeId?: string,
id: string,
type: "application" | "compose",
) => {
if (applicationId) {
return await db.query.patch.findFirst({
where: and(
eq(patch.filePath, filePath),
eq(patch.applicationId, applicationId),
),
});
}
if (composeId) {
return await db.query.patch.findFirst({
where: and(eq(patch.filePath, filePath), eq(patch.composeId, composeId)),
});
}
return null;
return await db.query.patch.findFirst({
where:
type === "application"
? and(eq(patch.filePath, filePath), eq(patch.applicationId, id))
: and(eq(patch.filePath, filePath), eq(patch.composeId, id)),
});
};
export const updatePatch = async (patchId: string, data: Partial<Patch>) => {