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