Skip to content

Commit

Permalink
feat(recent-documents): adds a recent documents list for macOS
Browse files Browse the repository at this point in the history
abstracts the file opening code to a function for reusability

fixes #527
2xAA committed May 4, 2021
1 parent 8c386cf commit 83f111b
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -248,6 +248,18 @@ protocol.registerSchemesAsPrivileged([
}
]);

function openFile(filePath) {
app.addRecentDocument(filePath);

windows["mainWindow"].webContents.send("open-preset", filePath);
}

app.on("open-file", (event, filePath) => {
event.preventDefault();

openFile(filePath);
});

const isMac = process.platform === "darwin";

function setCurrentProject(name) {
@@ -290,13 +302,26 @@ function generateMenuTemplate() {
});

if (!result.canceled) {
windows["mainWindow"].webContents.send(
"open-preset",
result.filePaths[0]
);
const filePath = result.filePaths[0];
openFile(filePath);
}
}
},
...(isMac
? [
{
label: "Open Recent",
role: "recentdocuments",
submenu: [
{
label: "Clear Recent",
role: "clearrecentdocuments"
}
]
}
]
: []),
{ type: "separator" },
{
label: "Save Preset",
accelerator: "CmdOrCtrl+Shift+S",

0 comments on commit 83f111b

Please sign in to comment.