Simplify handlers & IPC client: move from Result pattern to throwing errors (#120)

This commit is contained in:
Will Chen
2025-05-09 15:14:12 -07:00
committed by GitHub
parent 26305ee090
commit c71638a508
25 changed files with 618 additions and 990 deletions

View File

@@ -1,17 +1,21 @@
import { ipcMain } from "electron";
import { db } from "../../db";
import { messages, apps, chats } from "../../db/schema";
import { eq } from "drizzle-orm";
import { getDyadAppPath } from "../../paths/paths";
import { executeAddDependency } from "../processors/executeAddDependency";
import { createLoggedHandler } from "./safe_handle";
import log from "electron-log";
const logger = log.scope("dependency_handlers");
const handle = createLoggedHandler(logger);
export function registerDependencyHandlers() {
ipcMain.handle(
handle(
"chat:add-dep",
async (
_event,
{ chatId, packages }: { chatId: number; packages: string[] },
) => {
): Promise<void> => {
// Find the message from the database
const foundMessages = await db.query.messages.findMany({
where: eq(messages.chatId, chatId),