Delete chat (#77)
This commit is contained in:
@@ -63,4 +63,15 @@ export function registerChatHandlers() {
|
||||
return allChats;
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle("delete-chat", async (_, chatId: number) => {
|
||||
try {
|
||||
// Delete the chat and its associated messages
|
||||
await db.delete(chats).where(eq(chats.id, chatId));
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Error deleting chat:", error);
|
||||
return { success: false, error: (error as Error).message };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -277,7 +277,19 @@ export class IpcClient {
|
||||
public async createChat(appId: number): Promise<number> {
|
||||
try {
|
||||
const chatId = await this.ipcRenderer.invoke("create-chat", appId);
|
||||
return chatId;
|
||||
return chatId as number;
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteChat(chatId: number): Promise<{ success: boolean }> {
|
||||
try {
|
||||
const result = (await this.ipcRenderer.invoke("delete-chat", chatId)) as {
|
||||
success: boolean;
|
||||
};
|
||||
return result;
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user