Merge pull request #680 from yuya-oc/fix-mac-deeplink
Fix deep linking not working when the app is not already opened
This commit is contained in:
commit
f14df27409
|
@ -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;
|
||||
}
|
||||
|
|
15
src/main.js
15
src/main.js
|
@ -357,12 +357,23 @@ function setDeeplinkingUrl(url) {
|
|||
}
|
||||
}
|
||||
|
||||
// Protocol handler for osx
|
||||
app.on('open-url', (event, url) => {
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue