[MM-48079] Fix race condition related to registry loading vs. the welcome screen popup (#2408)

This commit is contained in:
Devin Binnie
2022-11-22 10:35:46 -04:00
committed by GitHub
parent 3c0d309697
commit 45e7ec95b7

View File

@@ -4,10 +4,11 @@
import {app, dialog, IpcMainEvent, IpcMainInvokeEvent, Menu} from 'electron';
import log from 'electron-log';
import {Team, TeamWithIndex} from 'types/config';
import {Team, TeamWithIndex, RegistryConfig as RegistryConfigType} 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';
@@ -87,6 +88,8 @@ 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();
return;
@@ -94,6 +97,17 @@ export function handleShowOnboardingScreens(showWelcomeScreen: boolean, showNewS
if (showNewServerModal) {
handleNewServerModal();
}
};
if (process.platform === 'win32' && !Config.registryConfigData) {
Config.registryConfig.once(REGISTRY_READ_EVENT, (data: Partial<RegistryConfigType>) => {
if (data.teams?.length === 0) {
showWelcomeScreenFunc();
}
});
} else {
showWelcomeScreenFunc();
}
}
export function handleMainWindowIsShown() {