ing
This commit is contained in:
parent
a9f514b9fb
commit
2ff4e28720
|
@ -49,61 +49,61 @@ process.on('uncaughtException', (error: Error) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
let handlingSquirrelEvent = false;
|
let handlingSquirrelEvent = false;
|
||||||
if (__WIN32__ && process.argv.length > 1) {
|
// if (__WIN32__ && process.argv.length > 1) {
|
||||||
const arg = process.argv[1];
|
// const arg = process.argv[1];
|
||||||
|
|
||||||
const promise = handleSquirrelEvent(arg);
|
// const promise = handleSquirrelEvent(arg);
|
||||||
if (promise) {
|
// if (promise) {
|
||||||
handlingSquirrelEvent = true;
|
// handlingSquirrelEvent = true;
|
||||||
promise
|
// promise
|
||||||
.catch(e => {
|
// .catch(e => {
|
||||||
log.error(`Failed handling Squirrel event: ${arg}`, e);
|
// log.error(`Failed handling Squirrel event: ${arg}`, e);
|
||||||
})
|
// })
|
||||||
.then(() => {
|
// .then(() => {
|
||||||
app.quit();
|
// app.quit();
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
handlePossibleProtocolLauncherArgs(process.argv);
|
// handlePossibleProtocolLauncherArgs(process.argv);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function handleAppURL(url: string) {
|
// function handleAppURL(url: string) {
|
||||||
log.info('Processing protocol url');
|
// log.info('Processing protocol url');
|
||||||
const action = parseAppURL(url);
|
// const action = parseAppURL(url);
|
||||||
onDidLoad(window => {
|
// onDidLoad(window => {
|
||||||
// This manual focus call _shouldn't_ be necessary, but is for Chrome on
|
// // This manual focus call _shouldn't_ be necessary, but is for Chrome on
|
||||||
// macOS. See https://github.com/desktop/desktop/issues/973.
|
// // macOS. See https://github.com/desktop/desktop/issues/973.
|
||||||
window.focus();
|
// window.focus();
|
||||||
window.sendURLAction(action);
|
// window.sendURLAction(action);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
let isDuplicateInstance = false;
|
let isDuplicateInstance = false;
|
||||||
// If we're handling a Squirrel event we don't want to enforce single instance.
|
// If we're handling a Squirrel event we don't want to enforce single instance.
|
||||||
// We want to let the updated instance launch and do its work. It will then quit
|
// We want to let the updated instance launch and do its work. It will then quit
|
||||||
// once it's done.
|
// once it's done.
|
||||||
if (!handlingSquirrelEvent) {
|
// if (!handlingSquirrelEvent) {
|
||||||
isDuplicateInstance = app.makeSingleInstance((args, workingDirectory) => {
|
// isDuplicateInstance = app.makeSingleInstance((args, workingDirectory) => {
|
||||||
// Someone tried to run a second instance, we should focus our window.
|
// // Someone tried to run a second instance, we should focus our window.
|
||||||
if (mainWindow) {
|
// if (mainWindow) {
|
||||||
if (mainWindow.isMinimized()) {
|
// if (mainWindow.isMinimized()) {
|
||||||
mainWindow.restore();
|
// mainWindow.restore();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!mainWindow.isVisible()) {
|
// if (!mainWindow.isVisible()) {
|
||||||
mainWindow.show();
|
// mainWindow.show();
|
||||||
}
|
// }
|
||||||
|
|
||||||
mainWindow.focus();
|
// mainWindow.focus();
|
||||||
}
|
// }
|
||||||
|
|
||||||
handlePossibleProtocolLauncherArgs(args);
|
// handlePossibleProtocolLauncherArgs(args);
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (isDuplicateInstance) {
|
// if (isDuplicateInstance) {
|
||||||
app.quit();
|
// app.quit();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (shellNeedsPatching(process)) {
|
if (shellNeedsPatching(process)) {
|
||||||
updateEnvironmentForProcess();
|
updateEnvironmentForProcess();
|
||||||
|
@ -113,7 +113,7 @@ app.on('will-finish-launching', () => {
|
||||||
// macOS only
|
// macOS only
|
||||||
app.on('open-url', (event, url) => {
|
app.on('open-url', (event, url) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handleAppURL(url);
|
// handleAppURL(url);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -125,26 +125,26 @@ app.on('will-finish-launching', () => {
|
||||||
* @param args Essentially process.argv, i.e. the first element is the exec
|
* @param args Essentially process.argv, i.e. the first element is the exec
|
||||||
* path
|
* path
|
||||||
*/
|
*/
|
||||||
function handlePossibleProtocolLauncherArgs(args: ReadonlyArray<string>) {
|
// function handlePossibleProtocolLauncherArgs(args: ReadonlyArray<string>) {
|
||||||
log.info(`Received possible protocol arguments: ${args.length}`);
|
// log.info(`Received possible protocol arguments: ${args.length}`);
|
||||||
|
|
||||||
if (__WIN32__) {
|
// if (__WIN32__) {
|
||||||
// We register our protocol handler callback on Windows as
|
// // We register our protocol handler callback on Windows as
|
||||||
// [executable path] --protocol-launcher -- "%1" meaning that any
|
// // [executable path] --protocol-launcher -- "%1" meaning that any
|
||||||
// url data comes after we've stopped processing arguments. We check
|
// // url data comes after we've stopped processing arguments. We check
|
||||||
// for that exact scenario here before doing any processing. If there's
|
// // for that exact scenario here before doing any processing. If there's
|
||||||
// more than 4 args because of a malformed url then we bail out.
|
// // more than 4 args because of a malformed url then we bail out.
|
||||||
if (
|
// if (
|
||||||
args.length === 4 &&
|
// args.length === 4 &&
|
||||||
args[1] === '--protocol-launcher' &&
|
// args[1] === '--protocol-launcher' &&
|
||||||
args[2] === '--'
|
// args[2] === '--'
|
||||||
) {
|
// ) {
|
||||||
handleAppURL(args[3]);
|
// handleAppURL(args[3]);
|
||||||
}
|
// }
|
||||||
} else if (args.length > 1) {
|
// } else if (args.length > 1) {
|
||||||
handleAppURL(args[1]);
|
// handleAppURL(args[1]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around app.setAsDefaultProtocolClient that adds our
|
* Wrapper around app.setAsDefaultProtocolClient that adds our
|
||||||
|
|
Loading…
Reference in New Issue
Block a user