From 8287126deb11a0c0091272d98bc50969272e18d4 Mon Sep 17 00:00:00 2001 From: James Hall Date: Tue, 13 Feb 2024 21:17:32 +0000 Subject: [PATCH] Recent documents menu (#1582) * Adds recent documents menu. * Removes erroneous import. * Open collection from recent document menu. --- packages/bruno-electron/src/app/menu-template.js | 10 ++++++++++ packages/bruno-electron/src/index.js | 4 ++++ packages/bruno-electron/src/ipc/collection.js | 1 + 3 files changed, 15 insertions(+) diff --git a/packages/bruno-electron/src/app/menu-template.js b/packages/bruno-electron/src/app/menu-template.js index c91740af1..2ac2276cf 100644 --- a/packages/bruno-electron/src/app/menu-template.js +++ b/packages/bruno-electron/src/app/menu-template.js @@ -12,6 +12,16 @@ const template = [ ipcMain.emit('main:open-collection'); } }, + { + label: 'Open Recent', + role: 'recentdocuments', + submenu: [ + { + label: 'Clear Recent', + role: 'clearrecentdocuments' + } + ] + }, { label: 'Preferences', accelerator: 'CommandOrControl+,', diff --git a/packages/bruno-electron/src/index.js b/packages/bruno-electron/src/index.js index d82b93a42..8c3fa1207 100644 --- a/packages/bruno-electron/src/index.js +++ b/packages/bruno-electron/src/index.js @@ -122,3 +122,7 @@ app.on('ready', async () => { // Quit the app once all windows are closed app.on('window-all-closed', app.quit); + +app.on('open-file', (event, path) => { + openCollection(mainWindow, watcher, path); +}) \ No newline at end of file diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index 9428eb4ec..ae47d6e06 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -617,6 +617,7 @@ const registerMainEventHandlers = (mainWindow, watcher, lastOpenedCollections) = ipcMain.on('main:collection-opened', (win, pathname, uid, brunoConfig) => { watcher.addWatcher(win, pathname, uid, brunoConfig); lastOpenedCollections.add(pathname); + app.addRecentDocument(pathname); }); // The app listen for this event and allows the user to save unsaved requests before closing the app