Convert to single-instance app

- Prevents multiple windows from being opens at once
 - Allows for URI launching by capturing argv from second process
This commit is contained in:
Alex Liebowitz 2017-05-10 04:44:06 -04:00
parent b189b31347
commit 856aa28db2
4 changed files with 25 additions and 0 deletions

View file

@ -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) {

1
lbry Submodule

@ -0,0 +1 @@
Subproject commit d99fc519b56ee910a44ef4af668b0770e9430d12

1
lbryschema Submodule

@ -0,0 +1 @@
Subproject commit 5c2441fa13e39ba7280292519041e14ec696d753

1
lbryum Submodule

@ -0,0 +1 @@
Subproject commit 950b95aa7e45a2c15b269d807f6ff8e16bae4304