Implement functionality for deleting notes

This commit is contained in:
Jonatan Heyman
2024-09-10 16:22:30 +02:00
parent 7be0a304d0
commit f0e299122f
5 changed files with 54 additions and 12 deletions

View File

@@ -96,6 +96,14 @@ export class FileLibrary {
await this.jetpack.moveAsync(fullOldPath, fullNewPath)
}
async delete(path) {
if (path === SCRATCH_FILE_NAME) {
throw new Error("Can't delete scratch file")
}
const fullPath = join(this.basePath, path)
await this.jetpack.removeAsync(fullPath)
}
async getList() {
//console.log("Listing notes")
const notes = {}
@@ -262,6 +270,10 @@ export function setupFileLibraryEventHandlers(win) {
return await library.move(path, newPath)
});
ipcMain.handle('buffer:delete', async (event, path) => {
return await library.delete(path)
});
ipcMain.handle("library:selectLocation", async () => {
let result = await dialog.showOpenDialog({
title: "Select directory to store buffer",