notes API cleanup

This commit is contained in:
nicwands
2026-02-23 14:19:07 -05:00
parent 7a670aab92
commit 9ac9d73b0a
8 changed files with 48 additions and 64 deletions

View File

@@ -61,9 +61,7 @@ const updateNote = (relativePath, content) => {
fs.writeFileSync(fullPath, content, "utf-8");
return true;
};
const notes = {
ensureBaseDir,
sanitizeRelativePath,
const notesAPI = {
readAllNotesRecursive,
createNote,
createDirectory,
@@ -123,27 +121,18 @@ electron.app.whenReady().then(() => {
utils.optimizer.watchWindowShortcuts(window);
});
createWindow();
notes.ensureBaseDir();
ensureBaseDir();
electron.app.on("activate", function() {
if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
});
electron.ipcMain.on("open-note-window", (_, noteId) => {
createNoteWindow(noteId);
});
electron.ipcMain.handle("notes:list", () => {
return notes.readAllNotesRecursive();
});
electron.ipcMain.handle("notes:create", (_, { path: path2, content }) => {
return notes.createNote(path2, content);
});
electron.ipcMain.handle("notes:createDir", (_, path2) => {
return notes.createDirectory(path2);
});
electron.ipcMain.handle("notes:read", (_, path2) => {
return notes.readNote(path2);
});
electron.ipcMain.handle("notes:update", (_, { path: path2, content }) => {
return notes.updateNote(path2, content);
electron.ipcMain.handle("notesAPI:call", async (_, method, args) => {
if (!notesAPI[method]) {
throw new Error("Invalid method");
}
return notesAPI[method](...args);
});
});
electron.app.on("window-all-closed", () => {