From 856aa28db2a7fbc3e39121ac1c3cea8d33ab94de Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 10 May 2017 04:44:06 -0400 Subject: [PATCH] Convert to single-instance app - Prevents multiple windows from being opens at once - Allows for URI launching by capturing argv from second process --- app/main.js | 22 ++++++++++++++++++++++ lbry | 1 + lbryschema | 1 + lbryum | 1 + 4 files changed, 25 insertions(+) create mode 160000 lbry create mode 160000 lbryschema create mode 160000 lbryum diff --git a/app/main.js b/app/main.js index 4fcf6572e..aa0cde89f 100644 --- a/app/main.js +++ b/app/main.js @@ -177,6 +177,27 @@ function quitNow() { app.quit(); } +const isSecondaryInstance = app.makeSingleInstance((argv) => { + if (process.argv.length < 3) { + return; + } + + if (!win) { + openUri = argv[2]; + } else { + if (win.isMinimized()) { + win.restore(); + win.focus(); + } + + win.webContents.send('open-uri-requested', argv[2]); + } +}); + +if (isSecondaryInstance) { // We're not in the original process, so quit + quitNow(); + return; +} app.on('ready', function(){ launchDaemonIfNotRunning(); @@ -316,6 +337,7 @@ function upgrade(event, installerPath) { ipcMain.on('upgrade', upgrade); app.setAsDefaultProtocolClient('lbry'); + if (process.platform == 'darwin') { app.on('open-url', (event, uri) => { if (!win) { diff --git a/lbry b/lbry new file mode 160000 index 000000000..d99fc519b --- /dev/null +++ b/lbry @@ -0,0 +1 @@ +Subproject commit d99fc519b56ee910a44ef4af668b0770e9430d12 diff --git a/lbryschema b/lbryschema new file mode 160000 index 000000000..5c2441fa1 --- /dev/null +++ b/lbryschema @@ -0,0 +1 @@ +Subproject commit 5c2441fa13e39ba7280292519041e14ec696d753 diff --git a/lbryum b/lbryum new file mode 160000 index 000000000..950b95aa7 --- /dev/null +++ b/lbryum @@ -0,0 +1 @@ +Subproject commit 950b95aa7e45a2c15b269d807f6ff8e16bae4304