diff --git a/src/common/config/index.ts b/src/common/config/index.ts index b342e354..abfa9a45 100644 --- a/src/common/config/index.ts +++ b/src/common/config/index.ts @@ -106,9 +106,17 @@ export class Config extends EventEmitter { if (process.platform === 'darwin' || process.platform === 'win32') { nativeTheme.on('updated', this.handleUpdateTheme); } - this.registryConfig = new RegistryConfig(); - this.registryConfig.once(REGISTRY_READ_EVENT, this.loadRegistry); - this.registryConfig.init(); + } + + initRegistry = () => { + return new Promise((resolve) => { + this.registryConfig = new RegistryConfig(); + this.registryConfig.once(REGISTRY_READ_EVENT, (data) => { + this.loadRegistry(data); + resolve(); + }); + this.registryConfig.init(); + }); } /** diff --git a/src/main/app/config.ts b/src/main/app/config.ts index e3b11386..7233f752 100644 --- a/src/main/app/config.ts +++ b/src/main/app/config.ts @@ -17,8 +17,6 @@ import WindowManager from 'main/windows/windowManager'; import {handleMainWindowIsShown} from './intercom'; import {handleUpdateMenuEvent, setLoggingLevel, updateServerInfos, updateSpellCheckerLocales} from './utils'; -let didCheckForAddServerModal = false; - // // config event handlers // @@ -63,12 +61,9 @@ export function handleConfigUpdate(newConfig: CombinedConfig) { }); } - if (process.platform === 'win32' && !didCheckForAddServerModal && typeof Config.registryConfigData !== 'undefined') { - didCheckForAddServerModal = true; - updateServerInfos(newConfig.teams); - WindowManager.initializeCurrentServerName(); - handleMainWindowIsShown(); - } + updateServerInfos(newConfig.teams); + WindowManager.initializeCurrentServerName(); + handleMainWindowIsShown(); handleUpdateMenuEvent(); if (newConfig.trayIconTheme) { diff --git a/src/main/app/initialize.test.js b/src/main/app/initialize.test.js index 64c767ad..0f3a698f 100644 --- a/src/main/app/initialize.test.js +++ b/src/main/app/initialize.test.js @@ -97,6 +97,7 @@ jest.mock('common/config', () => ({ once: jest.fn(), on: jest.fn(), init: jest.fn(), + initRegistry: jest.fn(), })); jest.mock('common/utils/url', () => ({ diff --git a/src/main/app/initialize.ts b/src/main/app/initialize.ts index f1031a72..613630f4 100644 --- a/src/main/app/initialize.ts +++ b/src/main/app/initialize.ts @@ -117,6 +117,7 @@ export async function initialize() { // wait for registry config data to load and app ready event await Promise.all([ app.whenReady(), + Config.initRegistry(), ]); // no need to continue initializing if app is quitting @@ -425,10 +426,7 @@ function initializeAfterAppReady() { callback(urlUtils.isTrustedURL(requestingURL, serverURL)); }); - // only check for non-Windows, as with Windows we have to wait for GPO teams - if (process.platform !== 'win32' || typeof Config.registryConfigData !== 'undefined') { - handleMainWindowIsShown(); - } + handleMainWindowIsShown(); } function handleStartDownload() { diff --git a/src/main/app/intercom.ts b/src/main/app/intercom.ts index c91a6be9..980a5ad5 100644 --- a/src/main/app/intercom.ts +++ b/src/main/app/intercom.ts @@ -4,11 +4,10 @@ import {app, dialog, IpcMainEvent, IpcMainInvokeEvent, Menu} from 'electron'; import log from 'electron-log'; -import {Team, TeamWithIndex, RegistryConfig as RegistryConfigType} from 'types/config'; +import {Team, TeamWithIndex} from 'types/config'; import {MentionData} from 'types/notification'; import Config from 'common/config'; -import {REGISTRY_READ_EVENT} from 'common/config/RegistryConfig'; import {getDefaultTeamWithTabsFromTeam} from 'common/tabs/TabView'; import {ping} from 'common/utils/requests'; @@ -89,36 +88,24 @@ export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName: export function handleShowOnboardingScreens(showWelcomeScreen: boolean, showNewServerModal: boolean, mainWindowIsVisible: boolean) { log.debug('Intercom.handleShowOnboardingScreens', {showWelcomeScreen, showNewServerModal, mainWindowIsVisible}); - const showWelcomeScreenFunc = () => { - if (showWelcomeScreen) { - handleWelcomeScreenModal(); + if (showWelcomeScreen) { + handleWelcomeScreenModal(); - if (process.env.NODE_ENV === 'test') { - const welcomeScreen = ModalManager.modalQueue.find((modal) => modal.key === 'welcomeScreen'); - if (welcomeScreen?.view.webContents.isLoading()) { - welcomeScreen?.view.webContents.once('did-finish-load', () => { - app.emit('e2e-app-loaded'); - }); - } else { + if (process.env.NODE_ENV === 'test') { + const welcomeScreen = ModalManager.modalQueue.find((modal) => modal.key === 'welcomeScreen'); + if (welcomeScreen?.view.webContents.isLoading()) { + welcomeScreen?.view.webContents.once('did-finish-load', () => { app.emit('e2e-app-loaded'); - } + }); + } else { + app.emit('e2e-app-loaded'); } - - return; } - if (showNewServerModal) { - handleNewServerModal(); - } - }; - if (process.platform === 'win32' && !Config.registryConfigData) { - Config.registryConfig.once(REGISTRY_READ_EVENT, (data: Partial) => { - if (data.teams?.length === 0) { - showWelcomeScreenFunc(); - } - }); - } else { - showWelcomeScreenFunc(); + return; + } + if (showNewServerModal) { + handleNewServerModal(); } }