From 758bb59ccb1d99e887436e69c84ed2787a35979e Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 5 May 2017 05:15:58 -0400 Subject: [PATCH] Add basics of URI handling for Mac and Windows --- app/main.js | 9 +++++++++ package.json | 8 ++++++++ ui/js/main.js | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/main.js b/app/main.js index eb867a2d7..3dcb85968 100644 --- a/app/main.js +++ b/app/main.js @@ -303,3 +303,12 @@ function upgrade(event, installerPath) { } ipcMain.on('upgrade', upgrade); + +if (process.platform == 'darwin') { + app.on('open-url', (event, uri) => { + win.webContents.send('open-uri-requested', url); + }); +} else if (process.argv.length >= 3) { + // No open-url event on Win, but we can still handle URIs provided at launch time + win.webContents.send('open-uri-requested', process.argv[2]); +} diff --git a/package.json b/package.json index 45142bbaa..af8cc1393 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,19 @@ }, "backgroundColor": "155B4A" }, + "protocols": [{ + "name": "lbry", + "role": "Viewer", + "schemes": ["lbry"] + }], "linux": { "target": "deb" }, "win": { "target": "nsis" + }, + "nsis": { + "perMachine": true } }, "devDependencies": { diff --git a/ui/js/main.js b/ui/js/main.js index 610ca8594..5985dbf6a 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -8,7 +8,7 @@ import SplashScreen from './component/splash.js'; import SnackBar from './component/snack-bar.js'; import {AuthOverlay} from './component/auth.js'; -const {remote} = require('electron'); +const {remote, ipcRenderer} = require('electron'); const contextMenu = remote.require('./menu/context-menu'); lbry.showMenuIfNeeded(); @@ -19,6 +19,10 @@ window.addEventListener('contextmenu', (event) => { event.preventDefault(); }); +ipcRenderer.on('open-uri-requested', (event, uri) => { + window.location.href = `?show=${uri}`; +}); + let init = function() { window.lbry = lbry; window.lighthouse = lighthouse;