notes API cleanup
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user