[MM-40574] Fix for race condition where new server modal didn't show initially on Linux, resizing issues (#1865)
* FIx for linux modal sizing * Fix race condition, merge'd
This commit is contained in:
@@ -7,7 +7,7 @@ import {RELOAD_CONFIGURATION} from 'common/communication';
|
||||
import Config from 'common/config';
|
||||
|
||||
import {handleConfigUpdate} from 'main/app/config';
|
||||
import {handleNewServerModal} from 'main/app/intercom';
|
||||
import {addNewServerModalWhenMainWindowIsShown} from 'main/app/intercom';
|
||||
import WindowManager from 'main/windows/windowManager';
|
||||
import AutoLauncher from 'main/AutoLauncher';
|
||||
|
||||
@@ -32,7 +32,7 @@ jest.mock('main/app/utils', () => ({
|
||||
updateServerInfos: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/app/intercom', () => ({
|
||||
handleNewServerModal: jest.fn(),
|
||||
addNewServerModalWhenMainWindowIsShown: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/AutoLauncher', () => ({
|
||||
enable: jest.fn(),
|
||||
@@ -98,7 +98,7 @@ describe('main/app/config', () => {
|
||||
Config.registryConfigData = {};
|
||||
|
||||
handleConfigUpdate({teams: []});
|
||||
expect(handleNewServerModal).toHaveBeenCalled();
|
||||
expect(addNewServerModalWhenMainWindowIsShown).toHaveBeenCalled();
|
||||
|
||||
Object.defineProperty(process, 'platform', {
|
||||
value: originalPlatform,
|
||||
|
@@ -14,7 +14,7 @@ import {setUnreadBadgeSetting} from 'main/badge';
|
||||
import {refreshTrayImages} from 'main/tray/tray';
|
||||
import WindowManager from 'main/windows/windowManager';
|
||||
|
||||
import {handleNewServerModal} from './intercom';
|
||||
import {addNewServerModalWhenMainWindowIsShown} from './intercom';
|
||||
import {handleUpdateMenuEvent, updateServerInfos, updateSpellCheckerLocales} from './utils';
|
||||
|
||||
let didCheckForAddServerModal = false;
|
||||
@@ -58,7 +58,7 @@ export function handleConfigUpdate(newConfig: CombinedConfig) {
|
||||
updateServerInfos(newConfig.teams);
|
||||
WindowManager.initializeCurrentServerName();
|
||||
if (newConfig.teams.length === 0) {
|
||||
handleNewServerModal();
|
||||
addNewServerModalWhenMainWindowIsShown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,9 @@ jest.mock('main/app/app', () => ({}));
|
||||
jest.mock('main/app/config', () => ({
|
||||
handleConfigUpdate: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/app/intercom', () => ({}));
|
||||
jest.mock('main/app/intercom', () => ({
|
||||
addNewServerModalWhenMainWindowIsShown: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/app/utils', () => ({
|
||||
clearAppCache: jest.fn(),
|
||||
getDeeplinkingURL: jest.fn(),
|
||||
|
@@ -63,6 +63,7 @@ import {
|
||||
} from './app';
|
||||
import {handleConfigUpdate, handleDarkModeChange} from './config';
|
||||
import {
|
||||
addNewServerModalWhenMainWindowIsShown,
|
||||
handleAppVersion,
|
||||
handleCloseTab,
|
||||
handleEditServerModal,
|
||||
@@ -373,9 +374,7 @@ function initializeAfterAppReady() {
|
||||
// only check for non-Windows, as with Windows we have to wait for GPO teams
|
||||
if (process.platform !== 'win32' || typeof Config.registryConfigData !== 'undefined') {
|
||||
if (Config.teams.length === 0) {
|
||||
setTimeout(() => {
|
||||
handleNewServerModal();
|
||||
}, 200);
|
||||
addNewServerModalWhenMainWindowIsShown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -76,6 +76,19 @@ export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName:
|
||||
Config.set('teams', teams);
|
||||
}
|
||||
|
||||
export function addNewServerModalWhenMainWindowIsShown() {
|
||||
const mainWindow = WindowManager.getMainWindow();
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isVisible()) {
|
||||
handleNewServerModal();
|
||||
} else {
|
||||
mainWindow.once('show', () => {
|
||||
handleNewServerModal();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function handleNewServerModal() {
|
||||
const html = getLocalURLString('newServer.html');
|
||||
|
||||
|
Reference in New Issue
Block a user