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

@@ -1,6 +1,6 @@
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import { app, shell, BrowserWindow, ipcMain } from 'electron'
import notes from './notesStorage'
import notesAPI, { ensureBaseDir } from './notesAPI'
import { join } from 'path'
const preloadPath = join(__dirname, '../preload/index.js')
@@ -78,7 +78,7 @@ app.whenReady().then(() => {
createWindow()
// Ensure data directory is present
notes.ensureBaseDir()
ensureBaseDir()
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
@@ -91,21 +91,12 @@ app.whenReady().then(() => {
createNoteWindow(noteId)
})
// File access
ipcMain.handle('notes:list', () => {
return notes.readAllNotesRecursive()
})
ipcMain.handle('notes:create', (_, { path, content }) => {
return notes.createNote(path, content)
})
ipcMain.handle('notes:createDir', (_, path) => {
return notes.createDirectory(path)
})
ipcMain.handle('notes:read', (_, path) => {
return notes.readNote(path)
})
ipcMain.handle('notes:update', (_, { path, content }) => {
return notes.updateNote(path, content)
// Handle calls to Notes API
ipcMain.handle('notesAPI:call', async (_, method, args) => {
if (!notesAPI[method]) {
throw new Error('Invalid method')
}
return notesAPI[method](...args)
})
})