Windows URI handling #121
5 changed files with 52 additions and 3 deletions
|
@ -44,6 +44,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
||||||
* Handle more of price calculations at the daemon layer to improve page load time
|
* Handle more of price calculations at the daemon layer to improve page load time
|
||||||
* Add special support for building channel claims in lbryuri module
|
* Add special support for building channel claims in lbryuri module
|
||||||
* Enable windows code signing of binary
|
* Enable windows code signing of binary
|
||||||
|
* Support for opening LBRY URIs from links in other apps
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -55,6 +56,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fix Watch page and progress bars for new API changes
|
* Fix Watch page and progress bars for new API changes
|
||||||
|
* On Windows, prevent opening multiple LBRY instances (launching LBRY again just focuses the current instance)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
50
app/main.js
50
app/main.js
|
@ -34,6 +34,22 @@ let readyToQuit = false;
|
||||||
// send it to, it's cached in this variable.
|
// send it to, it's cached in this variable.
|
||||||
let openUri = null;
|
let openUri = null;
|
||||||
|
|
||||||
|
function denormalizeUri(uri) {
|
||||||
|
// Windows normalizes URIs when they're passed in from other apps. 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') {
|
||||||
|
return uri.replace(/\/$/, '').replace('/#', '#');
|
||||||
|
} else {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkForNewVersion(callback) {
|
function checkForNewVersion(callback) {
|
||||||
function formatRc(ver) {
|
function formatRc(ver) {
|
||||||
// Adds dash if needed to make RC suffix semver friendly
|
// Adds dash if needed to make RC suffix semver friendly
|
||||||
|
@ -177,6 +193,29 @@ function quitNow() {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform != 'linux') {
|
||||||
|
// On Linux, this is always returning true due to an Electron bug,
|
||||||
|
// so for now we just don't support single-instance apps on Linux.
|
||||||
|
const isSecondaryInstance = app.makeSingleInstance((argv) => {
|
||||||
|
if (win) {
|
||||||
|
if (win.isMinimized()) {
|
||||||
|
win.restore();
|
||||||
|
}
|
||||||
|
win.focus();
|
||||||
|
|
||||||
|
if (argv.length >= 2) {
|
||||||
|
win.webContents.send('open-uri-requested', denormalizeUri(argv[1]));
|
||||||
|
}
|
||||||
|
} else if (argv.length >= 2) {
|
||||||
|
openUri = denormalizeUri(argv[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isSecondaryInstance) { // We're not in the original process, so quit
|
||||||
|
quitNow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.on('ready', function(){
|
app.on('ready', function(){
|
||||||
launchDaemonIfNotRunning();
|
launchDaemonIfNotRunning();
|
||||||
|
@ -315,6 +354,8 @@ function upgrade(event, installerPath) {
|
||||||
|
|
||||||
ipcMain.on('upgrade', upgrade);
|
ipcMain.on('upgrade', upgrade);
|
||||||
|
|
||||||
|
app.setAsDefaultProtocolClient('lbry');
|
||||||
|
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
app.on('open-url', (event, uri) => {
|
app.on('open-url', (event, uri) => {
|
||||||
if (!win) {
|
if (!win) {
|
||||||
|
@ -324,7 +365,10 @@ if (process.platform == 'darwin') {
|
||||||
win.webContents.send('open-uri-requested', uri);
|
win.webContents.send('open-uri-requested', uri);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (process.argv.length >= 3) {
|
} else if (process.argv.length >= 2) {
|
||||||
// No open-url event on Win, but we can still handle URIs provided at launch time
|
if (!win) {
|
||||||
win.webContents.send('open-uri-requested', process.argv[2]);
|
openUri = denormalizeUri(process.argv[1]);
|
||||||
|
} else {
|
||||||
|
win.webContents.send('open-uri-requested', denormalizeUri(process.argv[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
1
lbry
Submodule
1
lbry
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit d99fc519b56ee910a44ef4af668b0770e9430d12
|
1
lbryschema
Submodule
1
lbryschema
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5c2441fa13e39ba7280292519041e14ec696d753
|
1
lbryum
Submodule
1
lbryum
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 950b95aa7e45a2c15b269d807f6ff8e16bae4304
|
Loading…
Reference in a new issue