From 99828d048e075e69f1b86058c376559cc654911d Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Thu, 22 Mar 2018 11:55:11 -0400 Subject: [PATCH] fix: issue with second instance startup --- src/main/index.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index efd917060..851922dca 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -228,27 +228,29 @@ process.on('uncaughtException', error => { // Force single instance application const isSecondInstance = app.makeSingleInstance(argv => { - if ( - (process.platform === 'win32' || process.platform === 'linux') && - String(argv[1]).startsWith('lbry') - ) { - let URI = argv[1]; + if (rendererWindow) { + if ( + (process.platform === 'win32' || process.platform === 'linux') && + String(argv[1]).startsWith('lbry') + ) { + let URI = argv[1]; - // Keep only command line / deep linked arguments - // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to - // restore the original URI that was typed. - // - If the URI has no path, Windows adds a trailing slash. LBRY URIs can't have a slash with no - // path, so we just strip it off. - // - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as - // an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well. - if (process.platform === 'win32') { - URI = URI.replace(/\/$/, '').replace('/#', '#'); + // Keep only command line / deep linked arguments + // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to + // restore the original URI that was typed. + // - If the URI has no path, Windows adds a trailing slash. LBRY URIs can't have a slash with no + // path, so we just strip it off. + // - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as + // an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well. + if (process.platform === 'win32') { + URI = URI.replace(/\/$/, '').replace('/#', '#'); + } + + rendererWindow.webContents.send('open-uri-requested', URI); } - rendererWindow.webContents.send('open-uri-requested', URI); + rendererWindow.show(); } - - rendererWindow.show(); }); if (isSecondInstance) {