Merge pull request #1149 from lbryio/issue/1119

Repair deep linking and fix daemon quitting on auto update
This commit is contained in:
Igor Gassmann 2018-03-20 16:07:18 -04:00 committed by GitHub
commit 098a641688
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 15 deletions

View file

@ -34,6 +34,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
* Fix right click bug ([#928](https://github.com/lbryio/lbry-app/pull/928))
* Fix Election linting errors ([#929](https://github.com/lbryio/lbry-app/pull/929))
* App will no longer reset when minimizing to tray ([#1042](https://github.com/lbryio/lbry-app/pull/1042))
* Error when clicking LBRY URLs when app is closed on macOS ([#1119](https://github.com/lbryio/lbry-app/issues/1119))
* LBRY URLs not working on Linux ([#1120](https://github.com/lbryio/lbry-app/issues/1120))
* Fix Windows notifications not showing ([1145](https://github.com/lbryio/lbry-app/pull/1145))
### Deprecated

View file

@ -46,7 +46,8 @@
"target": "deb",
"category": "AudioVideo;Video",
"desktop": {
"MimeType": "x-scheme-handler/lbry;"
"MimeType": "x-scheme-handler/lbry",
"Exec": "/opt/LBRY/lbry %U"
}
},
"deb": {

View file

@ -33,8 +33,11 @@ export default appState => {
window.loadURL(rendererURL);
let deepLinkingURI;
// Protocol handler for win32
if (process.platform === 'win32' && String(process.argv[1]).startsWith('lbry')) {
if (
(process.platform === 'win32' || process.platform === 'linux') &&
String(process.argv[1]).startsWith('lbry')
) {
[, deepLinkingURI] = process.argv;
// 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.
@ -42,7 +45,11 @@ export default appState => {
// 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.
deepLinkingURI = process.argv[1].replace(/\/$/, '').replace('/#', '#');
if (process.platform === 'win32') {
deepLinkingURI = deepLinkingURI.replace(/\/$/, '').replace('/#', '#');
}
} else {
deepLinkingURI = appState.macDeepLinkingURI;
}
setupBarMenu();

View file

@ -66,8 +66,8 @@ app.on('ready', async () => {
'For more information please visit: \n' +
'https://lbry.io/faq/startup-troubleshooting'
);
app.quit();
}
app.quit();
});
daemon.launch();
}
@ -112,7 +112,10 @@ app.on('will-quit', event => {
}
appState.isQuitting = true;
if (daemon) daemon.quit();
if (daemon) {
daemon.quit();
event.preventDefault();
}
});
// https://electronjs.org/docs/api/app#event-will-finish-launching
@ -120,8 +123,13 @@ app.on('will-finish-launching', () => {
// Protocol handler for macOS
app.on('open-url', (event, URL) => {
event.preventDefault();
rendererWindow.webContents.send('open-uri-requested', URL);
rendererWindow.show();
if (rendererWindow) {
rendererWindow.webContents.send('open-uri-requested', URL);
rendererWindow.show();
} else {
appState.macDeepLinkingURI = URL;
}
});
});
@ -220,16 +228,26 @@ process.on('uncaughtException', error => {
// Force single instance application
const isSecondInstance = app.makeSingleInstance(argv => {
// Protocol handler for win32
// argv: An array of the second instances (command line / deep linked) arguments
if (
(process.platform === 'win32' || process.platform === 'linux') &&
String(argv[1]).startsWith('lbry')
) {
let URI = argv[1];
let URI;
if (process.platform === 'win32' && String(argv[1]).startsWith('lbry')) {
// Keep only command line / deep linked arguments
URI = argv[1].replace(/\/$/, '').replace('/#', '#');
// 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();
});

View file

@ -4,7 +4,6 @@ import SnackBar from 'component/snackBar';
import SplashScreen from 'component/splash';
import * as ACTIONS from 'constants/action_types';
import { ipcRenderer, remote, shell } from 'electron';
import lbry from 'lbry';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
@ -100,6 +99,11 @@ const init = () => {
app.store.dispatch(doAutoUpdate());
});
autoUpdater.on('error', (error) => {
// eslint-disable-next-line no-console
console.error(error.message)
});
if (['win32', 'darwin'].includes(process.platform)) {
autoUpdater.on('update-available', () => {
console.log('Update available');