make checkout version and revert version fit pattern (#118)

This commit is contained in:
Will Chen
2025-05-08 23:23:24 -07:00
committed by GitHub
parent 8d61659c60
commit c203b1d009
9 changed files with 161 additions and 92 deletions

View File

@@ -94,7 +94,7 @@ export function registerVersionHandlers() {
appId,
previousVersionId,
}: { appId: number; previousVersionId: string },
) => {
): Promise<void> => {
return withLock(appId, async () => {
const app = await db.query.apps.findFirst({
where: eq(apps.id, appId),
@@ -205,8 +205,6 @@ export function registerVersionHandlers() {
);
}
}
return { success: true };
} catch (error: any) {
logger.error(
`Error reverting to version ${previousVersionId} for app ${appId}:`,
@@ -220,7 +218,10 @@ export function registerVersionHandlers() {
ipcMain.handle(
"checkout-version",
async (_, { appId, versionId }: { appId: number; versionId: string }) => {
async (
_,
{ appId, versionId }: { appId: number; versionId: string },
): Promise<void> => {
return withLock(appId, async () => {
const app = await db.query.apps.findFirst({
where: eq(apps.id, appId),
@@ -240,8 +241,6 @@ export function registerVersionHandlers() {
ref: versionId,
force: true,
});
return { success: true };
} catch (error: any) {
logger.error(
`Error checking out version ${versionId} for app ${appId}:`,

View File

@@ -458,17 +458,11 @@ export class IpcClient {
}: {
appId: number;
previousVersionId: string;
}): Promise<{ success: boolean }> {
try {
const result = await this.ipcRenderer.invoke("revert-version", {
appId,
previousVersionId,
});
return result;
} catch (error) {
showError(error);
throw error;
}
}): Promise<void> {
await this.ipcRenderer.invoke("revert-version", {
appId,
previousVersionId,
});
}
// Checkout a specific version without creating a revert commit
@@ -478,17 +472,11 @@ export class IpcClient {
}: {
appId: number;
versionId: string;
}): Promise<{ success: boolean }> {
try {
const result = await this.ipcRenderer.invoke("checkout-version", {
appId,
versionId,
});
return result;
} catch (error) {
showError(error);
throw error;
}
}): Promise<void> {
await this.ipcRenderer.invoke("checkout-version", {
appId,
versionId,
});
}
// Get the current branch of an app