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