diff --git a/src/browser/components/MattermostView.jsx b/src/browser/components/MattermostView.jsx index 64b24cc1..8393d3c7 100644 --- a/src/browser/components/MattermostView.jsx +++ b/src/browser/components/MattermostView.jsx @@ -8,6 +8,8 @@ const {findDOMNode} = require('react-dom'); const {ipcRenderer, remote, shell} = require('electron'); const url = require('url'); const contextMenu = require('../js/contextMenu'); +const {protocols} = require('../../../electron-builder.json'); +const scheme = protocols[0].schemes[0]; const ErrorView = require('./ErrorView.jsx'); @@ -72,7 +74,7 @@ const MattermostView = createReactClass({ webview.addEventListener('new-window', (e) => { var currentURL = url.parse(webview.getURL()); var destURL = url.parse(e.url); - if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:') { + if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:' && destURL.protocol !== `${scheme}:`) { ipcRenderer.send('confirm-protocol', destURL.protocol, e.url); return; } diff --git a/src/main.js b/src/main.js index fb4235fb..944d5d41 100644 --- a/src/main.js +++ b/src/main.js @@ -357,12 +357,23 @@ function setDeeplinkingUrl(url) { } } -// Protocol handler for osx -app.on('open-url', (event, url) => { - event.preventDefault(); - setDeeplinkingUrl(url); - mainWindow.webContents.send('protocol-deeplink', deeplinkingUrl); - mainWindow.show(); +app.on('will-finish-launching', () => { + // Protocol handler for osx + app.on('open-url', (event, url) => { + event.preventDefault(); + setDeeplinkingUrl(url); + if (app.isReady()) { + function openDeepLink() { + try { + mainWindow.webContents.send('protocol-deeplink', deeplinkingUrl); + mainWindow.show(); + } catch (err) { + setTimeout(openDeepLink, 1000); + } + } + openDeepLink(); + } + }); }); // This method will be called when Electron has finished