mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 17:31:36 -06:00
Merge pull request #1010 from johankwarnmarksymphony/sda-2121
fix: Do not persist the client switch, new parameter isMana
This commit is contained in:
commit
a711e8d98d
@ -15,13 +15,6 @@ export enum CloudConfigDataTypes {
|
|||||||
ENABLED = 'ENABLED',
|
ENABLED = 'ENABLED',
|
||||||
DISABLED = 'DISABLED',
|
DISABLED = 'DISABLED',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ClientSwitchType {
|
|
||||||
CLIENT_1_5 = 'CLIENT_1_5',
|
|
||||||
CLIENT_2_0 = 'CLIENT_2_0',
|
|
||||||
CLIENT_2_0_DAILY = 'CLIENT_2_0_DAILY',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IConfig {
|
export interface IConfig {
|
||||||
url: string;
|
url: string;
|
||||||
minimizeOnClose: CloudConfigDataTypes;
|
minimizeOnClose: CloudConfigDataTypes;
|
||||||
@ -44,7 +37,6 @@ export interface IConfig {
|
|||||||
notificationSettings: INotificationSetting;
|
notificationSettings: INotificationSetting;
|
||||||
mainWinPos?: ICustomRectangle;
|
mainWinPos?: ICustomRectangle;
|
||||||
locale?: string;
|
locale?: string;
|
||||||
clientSwitch: ClientSwitchType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGlobalConfig {
|
export interface IGlobalConfig {
|
||||||
|
@ -9,7 +9,6 @@ import { IScreenSnippet } from '../common/api-interface';
|
|||||||
import { isDevEnv, isElectronQA, isLinux, isMac, isWindowsOS } from '../common/env';
|
import { isDevEnv, isElectronQA, isLinux, isMac, isWindowsOS } from '../common/env';
|
||||||
import { i18n } from '../common/i18n';
|
import { i18n } from '../common/i18n';
|
||||||
import { logger } from '../common/logger';
|
import { logger } from '../common/logger';
|
||||||
import { ClientSwitchType } from './config-handler';
|
|
||||||
import { updateAlwaysOnTop } from './window-actions';
|
import { updateAlwaysOnTop } from './window-actions';
|
||||||
import { windowHandler } from './window-handler';
|
import { windowHandler } from './window-handler';
|
||||||
import { windowExists } from './window-utils';
|
import { windowExists } from './window-utils';
|
||||||
@ -63,10 +62,10 @@ class ScreenSnippet {
|
|||||||
if (isMac) {
|
if (isMac) {
|
||||||
this.captureUtilArgs = [ '-i', '-s', '-t', 'png', this.outputFileName ];
|
this.captureUtilArgs = [ '-i', '-s', '-t', 'png', this.outputFileName ];
|
||||||
} else if (isWindowsOS) {
|
} else if (isWindowsOS) {
|
||||||
if (windowHandler.currentClient === ClientSwitchType.CLIENT_1_5) {
|
if (windowHandler.isMana) {
|
||||||
this.captureUtilArgs = [ this.outputFileName, i18n.getLocale() ];
|
|
||||||
} else {
|
|
||||||
this.captureUtilArgs = [ '--no-annotate', this.outputFileName, i18n.getLocale() ];
|
this.captureUtilArgs = [ '--no-annotate', this.outputFileName, i18n.getLocale() ];
|
||||||
|
} else {
|
||||||
|
this.captureUtilArgs = [ this.outputFileName, i18n.getLocale() ];
|
||||||
}
|
}
|
||||||
} else if (isLinux) {
|
} else if (isLinux) {
|
||||||
this.captureUtilArgs = ['-a', '-f', this.outputFileName];
|
this.captureUtilArgs = ['-a', '-f', this.outputFileName];
|
||||||
|
@ -21,7 +21,7 @@ import { getCommandLineArgs, getGuid } from '../common/utils';
|
|||||||
import { notification } from '../renderer/notification';
|
import { notification } from '../renderer/notification';
|
||||||
import { AppMenu } from './app-menu';
|
import { AppMenu } from './app-menu';
|
||||||
import { handleChildWindow } from './child-window-handler';
|
import { handleChildWindow } from './child-window-handler';
|
||||||
import { ClientSwitchType, CloudConfigDataTypes, config, IConfig, IGlobalConfig } from './config-handler';
|
import { CloudConfigDataTypes, config, IConfig, IGlobalConfig } from './config-handler';
|
||||||
import { SpellChecker } from './spell-check-handler';
|
import { SpellChecker } from './spell-check-handler';
|
||||||
import { checkIfBuildExpired } from './ttl-handler';
|
import { checkIfBuildExpired } from './ttl-handler';
|
||||||
import { versionHandler } from './version-handler';
|
import { versionHandler } from './version-handler';
|
||||||
@ -40,6 +40,12 @@ import {
|
|||||||
windowExists,
|
windowExists,
|
||||||
} from './window-utils';
|
} from './window-utils';
|
||||||
|
|
||||||
|
enum ClientSwitchType {
|
||||||
|
CLIENT_1_5 = 'CLIENT_1_5',
|
||||||
|
CLIENT_2_0 = 'CLIENT_2_0',
|
||||||
|
CLIENT_2_0_DAILY = 'CLIENT_2_0_DAILY',
|
||||||
|
}
|
||||||
|
|
||||||
interface ICustomBrowserWindowConstructorOpts extends Electron.BrowserWindowConstructorOptions {
|
interface ICustomBrowserWindowConstructorOpts extends Electron.BrowserWindowConstructorOptions {
|
||||||
winKey: string;
|
winKey: string;
|
||||||
}
|
}
|
||||||
@ -77,7 +83,7 @@ export class WindowHandler {
|
|||||||
public isOnline: boolean;
|
public isOnline: boolean;
|
||||||
public url: string | undefined;
|
public url: string | undefined;
|
||||||
public startUrl!: string;
|
public startUrl!: string;
|
||||||
public currentClient: ClientSwitchType = ClientSwitchType.CLIENT_1_5;
|
public isMana: boolean = false;
|
||||||
public willQuitApp: boolean = false;
|
public willQuitApp: boolean = false;
|
||||||
public spellchecker: SpellChecker | undefined;
|
public spellchecker: SpellChecker | undefined;
|
||||||
public isCustomTitleBar: boolean;
|
public isCustomTitleBar: boolean;
|
||||||
@ -295,13 +301,14 @@ export class WindowHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.url = this.mainWindow.webContents.getURL();
|
this.url = this.mainWindow.webContents.getURL();
|
||||||
|
logger.info('window-handler: did-finish-load, url: ' + this.url);
|
||||||
logger.info(`window-handler: client switch from config is ${this.config.clientSwitch}`);
|
const manaPath = 'client-bff';
|
||||||
|
if (this.url.includes(manaPath)) {
|
||||||
const parsedUrl = parse(this.url);
|
this.isMana = true;
|
||||||
if (this.url.startsWith('https://corporate.symphony.com') && this.url.indexOf(`https://${parsedUrl.hostname}/client/index.html`) !== -1) {
|
} else {
|
||||||
this.switchClient(this.config.clientSwitch ? this.config.clientSwitch : ClientSwitchType.CLIENT_2_0);
|
this.isMana = false;
|
||||||
}
|
}
|
||||||
|
logger.info('window-handler: isMana: ' + this.isMana);
|
||||||
|
|
||||||
// Injects custom title bar and snack bar css into the webContents
|
// Injects custom title bar and snack bar css into the webContents
|
||||||
await injectStyles(this.mainWindow, this.isCustomTitleBar);
|
await injectStyles(this.mainWindow, this.isCustomTitleBar);
|
||||||
@ -1219,14 +1226,7 @@ export class WindowHandler {
|
|||||||
* @param clientSwitch client switch you want to switch to.
|
* @param clientSwitch client switch you want to switch to.
|
||||||
*/
|
*/
|
||||||
private async switchClient(clientSwitch: ClientSwitchType): Promise<void> {
|
private async switchClient(clientSwitch: ClientSwitchType): Promise<void> {
|
||||||
|
|
||||||
if (this.currentClient && this.currentClient === clientSwitch) {
|
|
||||||
logger.info(`window handler: already in the same client ${clientSwitch}. Not switching!`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logger.info(`window handler: switch to client ${clientSwitch}`);
|
logger.info(`window handler: switch to client ${clientSwitch}`);
|
||||||
logger.info(`window handler: currentClient: ${this.currentClient}`);
|
|
||||||
this.currentClient = clientSwitch;
|
|
||||||
|
|
||||||
if (!this.mainWindow || !windowExists(this.mainWindow)) {
|
if (!this.mainWindow || !windowExists(this.mainWindow)) {
|
||||||
logger.info(`window-handler: switch client - main window web contents destroyed already! exiting`);
|
logger.info(`window-handler: switch client - main window web contents destroyed already! exiting`);
|
||||||
@ -1240,7 +1240,7 @@ export class WindowHandler {
|
|||||||
const manaPath = 'client-bff';
|
const manaPath = 'client-bff';
|
||||||
const manaChannel = 'daily';
|
const manaChannel = 'daily';
|
||||||
const csrfToken = await this.mainWindow.webContents.executeJavaScript(`localStorage.getItem('x-km-csrf-token')`);
|
const csrfToken = await this.mainWindow.webContents.executeJavaScript(`localStorage.getItem('x-km-csrf-token')`);
|
||||||
switch (this.currentClient) {
|
switch (clientSwitch) {
|
||||||
case ClientSwitchType.CLIENT_1_5:
|
case ClientSwitchType.CLIENT_1_5:
|
||||||
this.url = this.startUrl + `?x-km-csrf-token=${csrfToken}`;
|
this.url = this.startUrl + `?x-km-csrf-token=${csrfToken}`;
|
||||||
break;
|
break;
|
||||||
@ -1253,8 +1253,6 @@ export class WindowHandler {
|
|||||||
default:
|
default:
|
||||||
this.url = this.globalConfig.url + `?x-km-csrf-token=${csrfToken}`;
|
this.url = this.globalConfig.url + `?x-km-csrf-token=${csrfToken}`;
|
||||||
}
|
}
|
||||||
await config.updateUserConfig({ clientSwitch });
|
|
||||||
this.config.clientSwitch = clientSwitch;
|
|
||||||
await this.mainWindow.loadURL(this.url);
|
await this.mainWindow.loadURL(this.url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`window-handler: failed to switch client because of error ${e}`);
|
logger.error(`window-handler: failed to switch client because of error ${e}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user