From 2a591c80604ec158c8ac543fe969b6bff6ccd20d Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 1 Sep 2016 15:41:59 -0400 Subject: [PATCH] Wait to show the window until we've loaded --- app/src/main-process/app-window.ts | 7 +++++-- app/src/main-process/main.ts | 4 ++++ app/src/ui/index.tsx | 5 ++++- app/src/ui/main-process-proxy.ts | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main-process/app-window.ts b/app/src/main-process/app-window.ts index 2c27fc41d4..4eb91b39b6 100644 --- a/app/src/main-process/app-window.ts +++ b/app/src/main-process/app-window.ts @@ -58,8 +58,6 @@ export default class AppWindow { this.window.webContents.openDevTools() } - this.window.show() - const now = Date.now() this.sharedProcess.console.log(`Loading: ${now - startLoad}ms`) }) @@ -135,6 +133,11 @@ export default class AppWindow { this.window.focus() } + /** Show the window. */ + public show() { + this.window.show() + } + /** Send the menu event to the renderer. */ public sendMenuEvent(name: MenuEvent) { this.window.webContents.send('menu-event', { name }) diff --git a/app/src/main-process/main.ts b/app/src/main-process/main.ts index d967e543c7..ae1e17459b 100644 --- a/app/src/main-process/main.ts +++ b/app/src/main-process/main.ts @@ -112,6 +112,10 @@ app.on('ready', () => { fatalError(`Unknown menu id: ${id}`) } }) + + ipcMain.on('show-main-window', () => { + getMainWindow().show() + }) }) app.on('activate', () => { diff --git a/app/src/ui/index.tsx b/app/src/ui/index.tsx index 969483edf9..1f24cf0a2e 100644 --- a/app/src/ui/index.tsx +++ b/app/src/ui/index.tsx @@ -12,6 +12,7 @@ import { URLActionType } from '../lib/parse-url' import Repository from '../models/repository' import { find } from '../lib/find' import { getDefaultDir } from './lib/default-dir' +import { showMainWindow } from './main-process-proxy' if (!process.env.TEST_ENV) { /* This is the magic trigger for webpack to go compile @@ -23,7 +24,9 @@ const appStore = new AppStore() const gitUserStore = new GitUserStore(new GitUserDatabase('GitUserDatabase')) const cloningRepositoriesStore = new CloningRepositoriesStore() const dispatcher = new Dispatcher(appStore, gitUserStore, cloningRepositoriesStore) -dispatcher.loadInitialState() +dispatcher.loadInitialState().then(() => { + showMainWindow() +}) document.body.classList.add(`platform-${process.platform}`) diff --git a/app/src/ui/main-process-proxy.ts b/app/src/ui/main-process-proxy.ts index 4136d85866..2f1c0f8821 100644 --- a/app/src/ui/main-process-proxy.ts +++ b/app/src/ui/main-process-proxy.ts @@ -10,3 +10,8 @@ export function showPopupAppMenu() { export function setMenuEnabled(id: MenuIDs, enabled: boolean) { ipcRenderer.send('set-menu-enabled', [ { id, enabled } ]) } + +/** Show the main window. */ +export function showMainWindow() { + ipcRenderer.send('show-main-window') +}