Open in desktop #6667

Closed
btzr-io wants to merge 13 commits from protocol into master
2 changed files with 24 additions and 10 deletions
Showing only changes of commit 68d528003d - Show all commits

View file

@ -4,7 +4,7 @@
import '@babel/polyfill'; import '@babel/polyfill';
import SemVer from 'semver'; import SemVer from 'semver';
import https from 'https'; import https from 'https';
import { app, dialog, ipcMain, session, shell } from 'electron'; import { app, dialog, ipcMain, session, shell, protocol } from 'electron';
import { autoUpdater } from 'electron-updater'; import { autoUpdater } from 'electron-updater';
import { Lbry } from 'lbry-redux'; import { Lbry } from 'lbry-redux';
import LbryFirstInstance from './LbryFirstInstance'; import LbryFirstInstance from './LbryFirstInstance';
@ -46,8 +46,15 @@ let lbryFirst;
const appState = {}; const appState = {};
if (process.platform !== 'linux') { const PROTOCOL = 'lbry'
app.setAsDefaultProtocolClient('lbry');
if (isDev && process.platform === 'win32') {
// Setting this is required to get this working in dev mode.
app.setAsDefaultProtocolClient(PROTOCOL, process.execPath, [
path.resolve(process.argv[1])
]);
} else {
app.setAsDefaultProtocolClient(PROTOCOL);
} }
app.name = 'LBRY'; app.name = 'LBRY';
@ -149,9 +156,16 @@ if (!gotSingleInstanceLock) {
app.on('second-instance', (event, argv) => { app.on('second-instance', (event, argv) => {
// Send the url to the app to navigate first, then focus // Send the url to the app to navigate first, then focus
if (rendererWindow) { if (rendererWindow) {
if ((process.platform === 'win32' || process.platform === 'linux') && String(argv[1]).startsWith('lbry')) { // External uri (last item on argv):
let URI = argv[1]; // Required to work on dev mode
const EXTERNAL_URI = argv[argv.length ? (argv.length-1) : 0]
// Handle protocol requests for windows and linux
const platforms = (process.platform === 'win32' || process.platform === 'linux')
// Is LBRY protocol
const isProtocolURI = String(EXTERNAL_URI).startsWith(PROTOCOL)
// External protocol requested:
if (platforms && isProtocolURI) {
let URI = EXTERNAL_URI;
// Keep only command line / deep linked arguments // Keep only command line / deep linked arguments
// Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to
// restore the original URI that was typed. // restore the original URI that was typed.
@ -165,7 +179,7 @@ if (!gotSingleInstanceLock) {
.replace('/#', '#') .replace('/#', '#')
.replace('/?', '?'); .replace('/?', '?');
} }
rendererWindow.webContents.send('open-uri-requested', URI); rendererWindow.webContents.send('open-uri-requested', URI);
} }

View file

@ -2014,14 +2014,14 @@
"Chat": "Chat", "Chat": "Chat",
"Tipped": "Tipped", "Tipped": "Tipped",
"Fromage": "Fromage", "Fromage": "Fromage",
"In Favorites": "In Favorites", "In Favorites": "In Favorites",
"In Watch Later": "In Watch Later", "In Watch Later": "In Watch Later",
"In %lastCollectionName%": "In %lastCollectionName%", "In %lastCollectionName%": "In %lastCollectionName%",
"Remove from Watch Later": "Remove from Watch Later", "Remove from Watch Later": "Remove from Watch Later",
"Add to Watch Later": "Add to Watch Later", "Add to Watch Later": "Add to Watch Later",
"Added": "Added", "Added": "Added",
"Item added to Watch Later": "Item added to Watch Later", "Item added to Watch Later": "Item added to Watch Later",
"Item removed from Watch Later": "Item removed from Watch Later", "Item removed from Watch Later": "Item removed from Watch Later",
"Item added to %lastCollectionName%": "Item added to %lastCollectionName%", "Item added to %lastCollectionName%": "Item added to %lastCollectionName%",
"Item removed from %lastCollectionName%": "Item removed from %lastCollectionName%", "Item removed from %lastCollectionName%": "Item removed from %lastCollectionName%",
"Your publish is being confirmed and will be live soon": "Your publish is being confirmed and will be live soon", "Your publish is being confirmed and will be live soon": "Your publish is being confirmed and will be live soon",