fix(win): windows can re-launch with/without dev mode flag

Fixes https://github.com/nylas/N1/issues/2142
This commit is contained in:
Evan Morikawa 2016-05-09 13:36:46 -04:00
parent 335a20aabb
commit ae81f8f7c6
3 changed files with 18 additions and 12 deletions

View file

@ -44,20 +44,20 @@ export default class Application extends EventEmitter {
this.temporaryInitializeDisabledPackages();
// Normally, you enter dev mode by passing the --dev command line flag.
// But for developers using the compiled app, it's easier to toggle dev
// mode from the menu and have it persist through relaunch.
if (this.config.get('devMode')) {
this.devMode = true;
}
let initializeInBackground = options.background;
if (initializeInBackground === undefined) {
initializeInBackground = false;
}
this.autoUpdateManager = new AutoUpdateManager(version, config, specMode);
this.applicationMenu = new ApplicationMenu(version);
this.windowManager = new WindowManager({resourcePath, configDirPath, config, devMode, safeMode, initializeInBackground});
this.windowManager = new WindowManager({
resourcePath: this.resourcePath,
configDirPath: this.configDirPath,
config: this.config,
devMode: this.devMode,
safeMode: this.safeMode,
initializeInBackground: initializeInBackground,
});
this.systemTrayManager = new SystemTrayManager(process.platform, this);
this._databasePhase = 'setup';

View file

@ -15,7 +15,7 @@ const DEBUG_SHOW_HOT_WINDOW = false;
export default class WindowLauncher {
static EMPTY_WINDOW = "emptyWindow"
constructor({devMode, safeMode, resourcePath, configDirPath, onCreatedHotWindow}) {
constructor({devMode, safeMode, resourcePath, configDirPath, onCreatedHotWindow, config}) {
this.defaultWindowOpts = {
frame: process.platform !== "darwin",
hidden: false,
@ -28,12 +28,18 @@ export default class WindowLauncher {
resourcePath: resourcePath,
configDirPath: configDirPath,
}
this.config = config;
this.onCreatedHotWindow = onCreatedHotWindow;
this.createHotWindow();
}
newWindow(options) {
const opts = Object.assign({}, this.defaultWindowOpts, options);
// Normally, you enter dev mode by passing the --dev command line flag.
// But for developers using the compiled app, it's easier to toggle dev
// mode from the menu and have it persist through relaunch.
const devOpt = this.config.get('devMode') ? {devMode: true} : {};
const opts = Object.assign({}, this.defaultWindowOpts, devOpt, options);
let win;
if (this._mustUseColdWindow(opts)) {

View file

@ -9,7 +9,7 @@ const ONBOARDING_WINDOW = "onboarding"
export default class WindowManager {
constructor({devMode, safeMode, resourcePath, configDirPath, initializeInBackground}) {
constructor({devMode, safeMode, resourcePath, configDirPath, initializeInBackground, config}) {
this.initializeInBackground = initializeInBackground;
this._windows = {};
@ -17,7 +17,7 @@ export default class WindowManager {
this._registerWindow(win);
this._didCreateNewWindow(win);
}
this.windowLauncher = new WindowLauncher({devMode, safeMode, resourcePath, configDirPath, onCreatedHotWindow});
this.windowLauncher = new WindowLauncher({devMode, safeMode, resourcePath, configDirPath, config, onCreatedHotWindow});
}
get(windowKey) {