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:
1 parent
b189b31347
commit
856aa28db2
4 files changed
+25
No files matched your search
+22
@@ -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) {
|
||||
|
||||
Submodule
+1
Submodule lbry added at d99fc519b5.
Submodule
+1
Submodule lbryschema added at 5c2441fa13.
Submodule
+1
Submodule lbryum added at 950b95aa7e.
Reference in new issue
Block a user