update directory live
This commit is contained in:
@@ -97,12 +97,33 @@ app.whenReady().then(async () => {
|
||||
)
|
||||
await notesAPI.init()
|
||||
|
||||
// Broadcast note changes to all windows
|
||||
const broadcastNoteChange = (event, data) => {
|
||||
BrowserWindow.getAllWindows().forEach((win) => {
|
||||
win.webContents.send(event, data)
|
||||
})
|
||||
}
|
||||
|
||||
// Handle Notes API
|
||||
ipcMain.handle('notesAPI:call', (_, method, args) => {
|
||||
ipcMain.handle('notesAPI:call', async (_, method, args) => {
|
||||
if (!notesAPI[method]) {
|
||||
throw new Error('Invalid method')
|
||||
}
|
||||
return notesAPI[method](...args)
|
||||
|
||||
const result = await notesAPI[method](...args)
|
||||
|
||||
// Broadcast changes to all windows
|
||||
if (method === 'createNote') {
|
||||
broadcastNoteChange('note-created', result)
|
||||
} else if (method === 'updateNote') {
|
||||
broadcastNoteChange('note-updated', result)
|
||||
} else if (method === 'updateNoteMetadata') {
|
||||
broadcastNoteChange('note-updated', result)
|
||||
} else if (method === 'deleteNote') {
|
||||
broadcastNoteChange('note-deleted', { id: args[0] })
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
electronApp.setAppUserModelId('com.electron')
|
||||
|
||||
Reference in New Issue
Block a user