From aad616d927974142fbd759181bc50d32cf6ec550 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Mon, 25 Oct 2021 15:02:36 +0530 Subject: [PATCH] SDA-3409, SDA-3408, SDA-3402, SDA-3412 - Fix issues with electron bounds (#1274) * SDA-3409 - Fix view's x position w.r.t external display * SDA-3408 - Fix zoom controls for browserView * SDA-3409 - Use main window bounds for browser view * SDA-3409 - Fix blank welcome screen * SDA-3409 - Fix blank welcome screen * SDA-3402 - Create a separate window for the welcome screen * SDA-3409 - Fix view size issues * SDA-3409 - Workaround for electron fullscreen event * SDA-3402 - Fixes issue with maximize and unmaximize * SDA-3409 - Rename let to const --- .../windowsTitleBar.spec.ts.snap | 4 +- src/app/main-api-handler.ts | 9 +- src/app/window-actions.ts | 6 - src/app/window-handler.ts | 189 ++++++++++-------- src/app/window-utils.ts | 182 ++++++++++++----- src/common/api-interface.ts | 3 + src/renderer/components/welcome.tsx | 6 +- src/renderer/components/windows-title-bar.tsx | 2 +- src/renderer/preload-main.ts | 15 -- 9 files changed, 250 insertions(+), 166 deletions(-) diff --git a/spec/__snapshots__/windowsTitleBar.spec.ts.snap b/spec/__snapshots__/windowsTitleBar.spec.ts.snap index 9953f599..06a66aff 100644 --- a/spec/__snapshots__/windowsTitleBar.spec.ts.snap +++ b/spec/__snapshots__/windowsTitleBar.spec.ts.snap @@ -119,7 +119,7 @@ exports[`windows title bar should render correctly 1`] = ` onClick={[Function]} onContextMenu={[Function]} onMouseDown={[Function]} - title="Restore" + title="Maximize" > diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index 70fef95c..8a70890c 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -1,4 +1,5 @@ import { + app, BrowserWindow, clipboard, dialog, @@ -152,7 +153,8 @@ ipcMain.on( if ( browserWin && windowExists(browserWin) && - browserWin.winName === apiName.mainWindowName + (browserWin.winName === apiName.mainWindowName || + browserWin.winName === apiName.welcomeScreenName) ) { showPopupMenu({ window: browserWin }); } @@ -332,6 +334,11 @@ ipcMain.on( : mainWindow.unmaximize(); } break; + case apiCmds.setPodUrl: + await config.updateUserConfig({ url: arg.newPodUrl }); + app.relaunch(); + app.exit(); + break; default: break; } diff --git a/src/app/window-actions.ts b/src/app/window-actions.ts index d40aeef3..3356d0cf 100644 --- a/src/app/window-actions.ts +++ b/src/app/window-actions.ts @@ -292,12 +292,6 @@ const setSpecificAlwaysOnTop = () => { * @param window {BrowserWindow} */ export const monitorWindowActions = (window: BrowserWindow): void => { - if (windowHandler.shouldShowWelcomeScreen) { - logger.info( - `Not saving window position as we are showing the welcome window!`, - ); - return; - } if (!window || window.isDestroyed()) { return; } diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 5b31a600..ae6e7056 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -1,6 +1,7 @@ import { ExecException, execFile } from 'child_process'; import { app, + BrowserView, BrowserWindow, BrowserWindowConstructorOptions, crashReporter, @@ -104,8 +105,11 @@ export interface ICustomBrowserView extends Electron.BrowserView { } // Default window width & height -export let DEFAULT_WIDTH: number = 900; -export let DEFAULT_HEIGHT: number = 900; +export const DEFAULT_WIDTH: number = 900; +export const DEFAULT_HEIGHT: number = 900; +export const DEFAULT_WELCOME_SCREEN_WIDTH: number = 542; +export const DEFAULT_WELCOME_SCREEN_HEIGHT: number = 333; +export const TITLE_BAR_HEIGHT: number = 32; // Timeout on restarting SDA in case it's stuck const LISTEN_TIMEOUT: number = 25 * 1000; @@ -141,7 +145,6 @@ export class WindowHandler { public isWebPageLoading: boolean = true; public isLoggedIn: boolean = false; public screenShareIndicatorFrameUtil: string; - public shouldShowWelcomeScreen: boolean = false; private readonly defaultPodUrl: string = 'https://[POD].symphony.com'; private readonly contextIsolation: boolean; private readonly backgroundThrottling: boolean; @@ -154,6 +157,7 @@ export class WindowHandler { private loadFailError: string | undefined; private mainWindow: ICustomBrowserWindow | null = null; private aboutAppWindow: Electron.BrowserWindow | null = null; + private welcomeScreenWindow: Electron.BrowserWindow | null = null; private screenPickerWindow: Electron.BrowserWindow | null = null; private screenSharingIndicatorWindow: Electron.BrowserWindow | null = null; private screenSharingFrameWindow: Electron.BrowserWindow | null = null; @@ -272,7 +276,7 @@ export class WindowHandler { JSON.stringify(this.config.mainWinPos), ); - let { isFullScreen, isMaximized } = this.config.mainWinPos + const { isFullScreen, isMaximized } = this.config.mainWinPos ? this.config.mainWinPos : { isFullScreen: false, isMaximized: false }; @@ -281,35 +285,18 @@ export class WindowHandler { ); logger.info(`window-handler: setting url ${this.url} from config file!`); + // Get url to load from cmd line or from global config file + const urlFromCmd = getCommandLineArgs(process.argv, '--url=', false); + + // Displays welcome screen instead of starting the main application if ( config.isFirstTimeLaunch() && - this.globalConfig.url.indexOf('https://my.symphony.com') >= 0 + this.globalConfig.url.indexOf('https://my.symphony.com') >= 0 && + urlFromCmd === null ) { - this.shouldShowWelcomeScreen = true; this.url = this.defaultPodUrl; - isMaximized = false; - isFullScreen = false; - DEFAULT_HEIGHT = 333; - DEFAULT_WIDTH = 542; - this.windowOpts.resizable = false; - this.windowOpts.maximizable = false; - this.windowOpts.fullscreenable = false; - - if (this.config.mainWinPos && this.config.mainWinPos.height) { - this.config.mainWinPos.height = DEFAULT_HEIGHT; - } - - if (this.config.mainWinPos && this.config.mainWinPos.width) { - this.config.mainWinPos.width = DEFAULT_WIDTH; - } - - if (this.config.mainWinPos && this.config.mainWinPos.x) { - this.config.mainWinPos.x = undefined; - } - - if (this.config.mainWinPos && this.config.mainWinPos.y) { - this.config.mainWinPos.y = undefined; - } + this.showWelcomeScreen(); + return; } logger.info('window-handler: windowSize: ' + JSON.stringify(windowSize)); @@ -320,11 +307,9 @@ export class WindowHandler { logger.info( 'window-handler: windowSize: sizes: ' + JSON.stringify(sizes), ); - DEFAULT_WIDTH = Number(sizes[0]); - DEFAULT_HEIGHT = Number(sizes[1]); if (this.config.mainWinPos) { - this.config.mainWinPos.width = DEFAULT_WIDTH; - this.config.mainWinPos.height = DEFAULT_HEIGHT; + this.config.mainWinPos.width = Number(sizes[0]); + this.config.mainWinPos.height = Number(sizes[1]); } } @@ -340,8 +325,6 @@ export class WindowHandler { ); this.mainWindow.winName = apiName.mainWindowName; - // Get url to load from cmd line or from global config file - const urlFromCmd = getCommandLineArgs(process.argv, '--url=', false); if (urlFromCmd) { const commandLineUrl = urlFromCmd.substr(6); @@ -362,12 +345,6 @@ export class WindowHandler { `window-handler: setting ${commandLineUrl} from the command line as the main window url.`, ); this.url = commandLineUrl; - this.shouldShowWelcomeScreen = false; - isMaximized = true; - isFullScreen = false; - this.mainWindow.resizable = true; - this.mainWindow.maximizable = true; - this.mainWindow.fullScreenable = true; } else { logger.info( `window-handler: url ${commandLineUrl} from command line is NOT WHITELISTED in the config file.`, @@ -378,12 +355,6 @@ export class WindowHandler { `window-handler: setting ${commandLineUrl} from the command line as the main window url since pod whitelist is empty.`, ); this.url = commandLineUrl; - this.shouldShowWelcomeScreen = false; - isMaximized = true; - isFullScreen = false; - this.mainWindow.resizable = true; - this.mainWindow.maximizable = true; - this.mainWindow.fullScreenable = true; } } @@ -398,10 +369,6 @@ export class WindowHandler { } this.startUrl = this.url; - if (this.shouldShowWelcomeScreen) { - this.handleWelcomeScreen(); - } - cleanAppCacheOnCrash(this.mainWindow); // loads the main window with url from config/cmd line logger.info(`Loading main window with url ${this.url}`); @@ -431,7 +398,7 @@ export class WindowHandler { this.mainWindow.origin = this.globalConfig.contextOriginUrl || this.url; // Event needed to hide native menu bar on Windows 10 as we use custom menu bar - this.mainView?.webContents.once('did-start-loading', () => { + this.mainWebContents.once('did-start-loading', () => { logger.info( `window-handler: main window web contents started loading for url ${this.mainView?.webContents.getURL()}!`, ); @@ -708,60 +675,108 @@ export class WindowHandler { * Handles the use case of showing * welcome screen for first time installs */ - public handleWelcomeScreen() { - if (!this.url || !this.mainWindow) { + public showWelcomeScreen() { + if (!this.url) { return; } + const opts: ICustomBrowserWindowConstructorOpts = this.getWindowOpts( + { + width: DEFAULT_WELCOME_SCREEN_WIDTH, + height: DEFAULT_WELCOME_SCREEN_HEIGHT, + frame: !this.isCustomTitleBar, + alwaysOnTop: isMac, + resizable: false, + minimizable: false, + fullscreenable: false, + }, + { + devTools: isDevEnv, + }, + ); - if (this.url.startsWith(this.defaultPodUrl)) { - this.url = format({ + this.welcomeScreenWindow = createComponentWindow('welcome', opts); + (this.welcomeScreenWindow as ICustomBrowserWindow).winName = + apiName.welcomeScreenName; + + if ( + this.config.isCustomTitleBar === CloudConfigDataTypes.ENABLED && + isWindowsOS + ) { + const titleBarView = new BrowserView({ + webPreferences: { + sandbox: !isNodeEnv, + nodeIntegration: isNodeEnv, + preload: path.join(__dirname, '../renderer/_preload-component.js'), + devTools: isDevEnv, + }, + }) as ICustomBrowserView; + const titleBarWindowUrl = format({ pathname: require.resolve('../renderer/react-window.html'), protocol: 'file', query: { - componentName: 'welcome', + componentName: 'title-bar', locale: i18n.getLocale(), }, slashes: true, }); + + titleBarView.webContents.once('did-finish-load', async () => { + if (!titleBarView || titleBarView.webContents.isDestroyed()) { + return; + } + titleBarView?.webContents.send('page-load', { + isWindowsOS, + locale: i18n.getLocale(), + resource: i18n.loadedResources, + isMainWindow: true, + }); + }); + titleBarView.webContents.loadURL(titleBarWindowUrl); + titleBarView.setBounds({ + x: 0, + y: 0, + height: TITLE_BAR_HEIGHT, + width: DEFAULT_WELCOME_SCREEN_WIDTH, + }); + this.welcomeScreenWindow.setBrowserView(titleBarView); } - this.mainWindow.webContents.on('did-finish-load', () => { - if (!this.url || !this.mainWindow) { + this.welcomeScreenWindow.webContents.on('did-finish-load', () => { + if (!this.welcomeScreenWindow || this.welcomeScreenWindow.isDestroyed()) { return; } logger.info(`finished loading welcome screen.`); - if (this.url.indexOf('welcome')) { - const ssoValue = !!( - this.userConfig.url && - this.userConfig.url.indexOf('/login/sso/initsso') > -1 - ); + const ssoValue = !!( + this.userConfig.url && + this.userConfig.url.indexOf('/login/sso/initsso') > -1 + ); - this.mainWindow.webContents?.send('page-load-welcome', { - locale: i18n.getLocale(), - resource: i18n.loadedResources, - }); - const userConfigUrl = - this.userConfig.url && - this.userConfig.url.indexOf('/login/sso/initsso') > -1 - ? this.userConfig.url.slice( - 0, - this.userConfig.url.indexOf('/login/sso/initsso'), - ) - : this.userConfig.url; + this.welcomeScreenWindow.webContents.send('page-load-welcome', { + locale: i18n.getLocale(), + resource: i18n.loadedResources, + }); - this.mainWindow.webContents?.send('welcome', { - url: userConfigUrl || this.startUrl, - message: '', - urlValid: !!userConfigUrl, - sso: ssoValue, - }); - } + const userConfigUrl = + this.userConfig.url && + this.userConfig.url.indexOf('/login/sso/initsso') > -1 + ? this.userConfig.url.slice( + 0, + this.userConfig.url.indexOf('/login/sso/initsso'), + ) + : this.userConfig.url; + this.welcomeScreenWindow.webContents.send('welcome', { + url: userConfigUrl || this.startUrl, + message: '', + urlValid: !!userConfigUrl, + sso: ssoValue, + }); + this.addWindow(opts.winKey, this.welcomeScreenWindow); + this.mainWindow = this.welcomeScreenWindow as ICustomBrowserWindow; }); - ipcMain.on('set-pod-url', async (_event, newPodUrl: string) => { - await config.updateUserConfig({ url: newPodUrl }); - app.relaunch(); - app.exit(); + this.welcomeScreenWindow.once('closed', () => { + this.removeWindow(opts.winKey); + this.welcomeScreenWindow = null; }); } diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index d9d87d5e..852630b4 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -43,6 +43,7 @@ import { DEFAULT_WIDTH, ICustomBrowserView, ICustomBrowserWindow, + TITLE_BAR_HEIGHT, windowHandler, } from './window-handler'; @@ -60,10 +61,7 @@ enum styleNames { } const checkValidWindow = true; -const { ctWhitelist, mainWinPos } = config.getConfigFields([ - 'ctWhitelist', - 'mainWinPos', -]); +const { ctWhitelist } = config.getConfigFields(['ctWhitelist']); // Network status check variables const networkStatusCheckInterval = 10 * 1000; @@ -256,14 +254,19 @@ export const showBadgeCount = (count: number): void => { // handle ms windows... const mainWindow = windowHandler.getMainWindow(); - if (!mainWindow || !windowExists(mainWindow)) { + const mainWebContents = windowHandler.getMainWebContents(); + if (!mainWebContents || mainWebContents.isDestroyed()) { return; } // get badge img from renderer process, will return // img dataUrl in setDataUrl func. if (count > 0) { - mainWindow.webContents.send('create-badge-data-url', { count }); + mainWebContents.send('create-badge-data-url', { count }); + return; + } + + if (!mainWindow || !windowExists(mainWindow)) { return; } @@ -770,7 +773,18 @@ export const zoomIn = () => { return; } - const { webContents } = focusedWindow; + let { webContents } = focusedWindow; + + // If the focused window is mainWindow we should use mainWebContents + if ( + (focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName + ) { + const mainWebContents = windowHandler.mainWebContents; + if (mainWebContents && !mainWebContents.isDestroyed()) { + webContents = mainWebContents; + } + } + if (windowHandler.isMana) { const zoomFactor = webContents.getZoomFactor(); if (zoomFactor < 1.5) { @@ -791,8 +805,8 @@ export const zoomIn = () => { } } } else { - const currentZoomLevel = focusedWindow.webContents.getZoomLevel(); - focusedWindow.webContents.setZoomLevel(currentZoomLevel + 0.5); + const currentZoomLevel = webContents.getZoomLevel(); + webContents.setZoomLevel(currentZoomLevel + 0.5); } }; @@ -810,7 +824,18 @@ export const zoomOut = () => { return; } - const { webContents } = focusedWindow; + let { webContents } = focusedWindow; + + // If the focused window is mainWindow we should use mainWebContents + if ( + (focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName + ) { + const mainWebContents = windowHandler.mainWebContents; + if (mainWebContents && !mainWebContents.isDestroyed()) { + webContents = mainWebContents; + } + } + if (windowHandler.isMana) { const zoomFactor = webContents.getZoomFactor(); if (zoomFactor > 0.7) { @@ -831,8 +856,8 @@ export const zoomOut = () => { } } } else { - const currentZoomLevel = focusedWindow.webContents.getZoomLevel(); - focusedWindow.webContents.setZoomLevel(currentZoomLevel - 0.5); + const currentZoomLevel = webContents.getZoomLevel(); + webContents.setZoomLevel(currentZoomLevel - 0.5); } }; @@ -845,7 +870,17 @@ export const resetZoomLevel = () => { if (!focusedWindow || !windowExists(focusedWindow)) { return; } - focusedWindow.webContents.setZoomLevel(0); + let { webContents } = focusedWindow; + // If the focused window is mainWindow we should use mainWebContents + if ( + (focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName + ) { + const mainWebContents = windowHandler.mainWebContents; + if (mainWebContents && !mainWebContents.isDestroyed()) { + webContents = mainWebContents; + } + } + webContents.setZoomLevel(0); }; /** @@ -893,7 +928,7 @@ export const updateFeaturesForCloudConfig = async (): Promise => { 'memoryThreshold', ]) as IConfig; - const mainWindow = windowHandler.getMainWindow(); + const mainWebContents = windowHandler.getMainWebContents(); // Update Always on top feature await updateAlwaysOnTop( @@ -907,14 +942,14 @@ export const updateFeaturesForCloudConfig = async (): Promise => { ? autoLaunchInstance.enableAutoLaunch() : autoLaunchInstance.disableAutoLaunch(); - if (mainWindow && windowExists(mainWindow)) { + if (mainWebContents && !mainWebContents.isDestroyed()) { if (memoryRefresh) { logger.info( `window-utils: updating the memory threshold`, memoryThreshold, ); memoryMonitor.setMemoryThreshold(parseInt(memoryThreshold, 10)); - mainWindow.webContents.send('initialize-memory-refresh'); + mainWebContents.send('initialize-memory-refresh'); } } }; @@ -933,19 +968,19 @@ export const monitorNetworkInterception = (url: string) => { return; } - const mainWindow = windowHandler.getMainWindow(); + const mainWebContents = windowHandler.getMainWebContents(); const podUrl = `${protocol}//${hostname}/`; logger.info('window-utils: monitoring network interception for url', podUrl); // Filter applied w.r.t pod url const filter = { urls: [podUrl + '*'] }; - if (mainWindow && windowExists(mainWindow)) { + if (mainWebContents && !mainWebContents.isDestroyed()) { isNetworkMonitorInitialized = true; - mainWindow.webContents.session.webRequest.onErrorOccurred( + mainWebContents.session.webRequest.onErrorOccurred( filter, async (details) => { - if (!mainWindow || !windowExists(mainWindow)) { + if (!mainWebContents || mainWebContents.isDestroyed()) { return; } if ( @@ -956,7 +991,7 @@ export const monitorNetworkInterception = (url: string) => { details.error === 'net::ERR_NAME_NOT_RESOLVED') ) { logger.error(`window-utils: URL failed to load`, details); - mainWindow.webContents.send('show-banner', { + mainWebContents.send('show-banner', { show: true, bannerType: 'error', url: podUrl, @@ -982,9 +1017,15 @@ export const loadBrowserViews = async ( devTools: isDevEnv, }, }) as ICustomBrowserView; + const mainWindowBounds = windowHandler.getMainWindow()?.getBounds(); const mainView = new BrowserView({ ...windowHandler.getMainWindowOpts(), - ...getBounds(mainWinPos, DEFAULT_WIDTH, DEFAULT_HEIGHT), + ...{ + width: mainWindowBounds?.width || DEFAULT_WIDTH, + height: mainWindowBounds?.height || DEFAULT_HEIGHT, + x: 0, + y: TITLE_BAR_HEIGHT, + }, }) as ICustomBrowserView; mainWindow.addBrowserView(titleBarView); @@ -1015,52 +1056,82 @@ export const loadBrowserViews = async ( ); mainWindow?.on('enter-full-screen', () => { - if (!titleBarView || !viewExists(titleBarView)) { - return; - } - const titleBarBounds = titleBarView.getBounds(); - titleBarView.setBounds({ ...titleBarBounds, ...{ height: 0 } }); - if ( - !mainView || - !viewExists(mainView) || + !titleBarView || + !viewExists(titleBarView) || !mainWindow || !windowExists(mainWindow) ) { return; } - const mainWindowBounds = mainWindow.getBounds(); - const mainViewBounds = mainView.getBounds(); - mainView.setBounds({ - width: mainWindowBounds.width, - height: mainViewBounds.height, - x: 0, - y: 0, - }); + // Workaround: Need to delay getting the window bounds + // to get updated window bounds + setTimeout(() => { + const [width, height] = mainWindow.getSize(); + titleBarView.setBounds({ x: 0, y: 0, width, height: 0 }); + + if (!mainView || !viewExists(mainView)) { + return; + } + mainView.setBounds({ + width, + height, + x: 0, + y: 0, + }); + }, 500); }); mainWindow?.on('leave-full-screen', () => { - if (!titleBarView || !viewExists(titleBarView)) { - return; - } - const titleBarBounds = titleBarView.getBounds(); - titleBarView.setBounds({ ...titleBarBounds, ...{ height: 32 } }); - if ( - !mainView || - !viewExists(mainView) || + !titleBarView || + !viewExists(titleBarView) || !mainWindow || !windowExists(mainWindow) ) { return; } - const mainWindowBounds = mainWindow.getBounds(); + // Workaround: Need to delay getting the window bounds + // to get updated window bounds + setTimeout(() => { + const [width, height] = mainWindow.getSize(); + titleBarView.setBounds({ x: 0, y: 0, width, height: TITLE_BAR_HEIGHT }); + if (!mainView || !viewExists(mainView)) { + return; + } + mainView.setBounds({ + width, + height, + x: 0, + y: TITLE_BAR_HEIGHT, + }); + }, 500); + }); + + mainWindow?.on('maximize', () => { + if (!mainView || !viewExists(mainView)) { + return; + } + const [width, height] = mainWindow.getSize(); mainView.setBounds({ - width: mainWindowBounds.width, - height: mainWindowBounds.height, - x: mainWindowBounds.x, - y: 32, + width, + height, + x: 0, + y: TITLE_BAR_HEIGHT, }); }); + mainWindow?.on('unmaximize', () => { + if (!mainView || !viewExists(mainView)) { + return; + } + const [width, height] = mainWindow.getSize(); + mainView.setBounds({ + width, + height, + x: 0, + y: TITLE_BAR_HEIGHT, + }); + }); + if (mainWindow?.isMaximized()) { mainEvents.publish('maximize'); } @@ -1071,7 +1142,7 @@ export const loadBrowserViews = async ( await titleBarView.webContents.loadURL(titleBarWindowUrl); titleBarView.setBounds({ ...mainWindow.getBounds(), - ...{ x: 0, y: 0, height: 32 }, + ...{ x: 0, y: 0, height: TITLE_BAR_HEIGHT }, }); titleBarView.setAutoResize({ vertical: false, @@ -1081,7 +1152,12 @@ export const loadBrowserViews = async ( }); await mainView.webContents.loadURL(url, { userAgent }); - mainView.setBounds({ ...mainWindow.getBounds(), ...{ y: 32 } }); + mainView.setBounds({ + width: mainWindowBounds?.width || DEFAULT_WIDTH, + height: mainWindowBounds?.height || DEFAULT_HEIGHT, + x: 0, + y: TITLE_BAR_HEIGHT, + }); mainView.setAutoResize({ horizontal: true, vertical: false, diff --git a/src/common/api-interface.ts b/src/common/api-interface.ts index 64400741..89b028fc 100644 --- a/src/common/api-interface.ts +++ b/src/common/api-interface.ts @@ -57,12 +57,14 @@ export enum apiCmds { isAeroGlassEnabled = 'is-aero-glass-enabled', showScreenSharePermissionDialog = 'show-screen-share-permission-dialog', getMediaAccessStatus = 'get-media-access-status', + setPodUrl = 'set-pod-url', } export enum apiName { symphonyApi = 'symphony-api', mainWindowName = 'main', notificationWindowName = 'notification-window', + welcomeScreenName = 'welcome-screen', } export const NOTIFICATION_WINDOW_TITLE = 'Notification - Symphony'; @@ -102,6 +104,7 @@ export interface IApiArgs { clipboardType: 'clipboard' | 'selection'; requestId: number; mediaStatus: IMediaPermission; + newPodUrl: string; } export type Themes = 'light' | 'dark'; diff --git a/src/renderer/components/welcome.tsx b/src/renderer/components/welcome.tsx index 64526526..f693e7cd 100644 --- a/src/renderer/components/welcome.tsx +++ b/src/renderer/components/welcome.tsx @@ -1,5 +1,6 @@ import { ipcRenderer } from 'electron'; import * as React from 'react'; +import { apiCmds, apiName } from '../../common/api-interface'; import { i18n } from '../../common/i18n-preload'; interface IState { @@ -107,7 +108,10 @@ export default class Welcome extends React.Component<{}, IState> { if (url.endsWith('/')) { ssoPath = 'login/sso/initsso'; } - ipcRenderer.send('set-pod-url', sso ? `${url}${ssoPath}` : url); + ipcRenderer.send(apiName.symphonyApi, { + cmd: apiCmds.setPodUrl, + newPodUrl: sso ? `${url}${ssoPath}` : url, + }); } /** diff --git a/src/renderer/components/windows-title-bar.tsx b/src/renderer/components/windows-title-bar.tsx index 466d9989..e58bf377 100644 --- a/src/renderer/components/windows-title-bar.tsx +++ b/src/renderer/components/windows-title-bar.tsx @@ -27,7 +27,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { this.state = { title: document.title || 'Symphony', isFullScreen: false, - isMaximized: true, + isMaximized: false, }; // Adds borders to the window this.addWindowBorders(); diff --git a/src/renderer/preload-main.ts b/src/renderer/preload-main.ts index db8d51ed..b13f6d86 100644 --- a/src/renderer/preload-main.ts +++ b/src/renderer/preload-main.ts @@ -9,7 +9,6 @@ import DownloadManager from './components/download-manager'; import MessageBanner from './components/message-banner'; import NetworkError from './components/network-error'; import SnackBar from './components/snack-bar'; -import Welcome from './components/welcome'; import { SSFApi } from './ssf-api'; interface ISSFWindow extends Window { @@ -152,20 +151,6 @@ ipcRenderer.on('page-load', (_event, { locale, resources }) => { banner.showBanner(false, 'error'); }); -ipcRenderer.on('page-load-welcome', (_event, data) => { - const { locale, resource } = data; - i18n.setResource(locale, resource); - - document.title = 'Welcome'; - const styles = document.createElement('link'); - styles.rel = 'stylesheet'; - styles.type = 'text/css'; - styles.href = `./styles/welcome.css`; - document.getElementsByTagName('head')[0].appendChild(styles); - const element = React.createElement(Welcome); - ReactDOM.render(element, document.getElementById('Root')); -}); - // When the window fails to load ipcRenderer.on('page-load-failed', (_event, { locale, resources }) => { i18n.setResource(locale, resources);