chore: format the problematic files

This commit is contained in:
Vishwas Shashidhar 2021-01-29 13:10:30 +05:30
parent 2c4773d4e5
commit 396dc4e950
17 changed files with 138 additions and 138 deletions

View File

@ -189,7 +189,7 @@
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "pretty-quick --staged" "pre-commit": "pretty-quick --staged && npm run lint"
} }
} }
} }

View File

@ -60,7 +60,8 @@ export const stopApplication = async (
if (!application || !application.isRunning()) { if (!application || !application.isRunning()) {
return; return;
} }
return await application.stop(); await application.stop();
return;
}; };
/** /**

View File

@ -1,5 +1,4 @@
import * as electron from 'electron'; import { app, powerMonitor } from 'electron';
import { app } from 'electron';
import Timer = NodeJS.Timer; import Timer = NodeJS.Timer;
import { logger } from '../common/logger'; import { logger } from '../common/logger';
@ -44,7 +43,7 @@ class ActivityDetection {
if (app.isReady()) { if (app.isReady()) {
logger.info(`activity-detection: Starting activity monitor`); logger.info(`activity-detection: Starting activity monitor`);
this.queryInterval = setInterval(() => { this.queryInterval = setInterval(() => {
const idleTime = electron.powerMonitor.getSystemIdleTime(); const idleTime = powerMonitor.getSystemIdleTime();
this.activity(idleTime); this.activity(idleTime);
}, this.idleThreshold); }, this.idleThreshold);
} }
@ -81,7 +80,7 @@ class ActivityDetection {
// when user goes inactive // when user goes inactive
this.timer = setInterval(() => { this.timer = setInterval(() => {
if (app.isReady()) { if (app.isReady()) {
const activeTime = electron.powerMonitor.getSystemIdleTime(); const activeTime = powerMonitor.getSystemIdleTime();
this.activity(activeTime); this.activity(activeTime);
} }
}, 1000); }, 1000);

View File

@ -32,10 +32,11 @@ export const menuSections = {
edit: 'edit', edit: 'edit',
view: 'view', view: 'view',
window: 'window', window: 'window',
help: 'help', // tslint:disable-line help: 'help',
}; };
const windowsAccelerator = Object.assign({ const windowsAccelerator = {
...{
close: 'Ctrl+W', close: 'Ctrl+W',
copy: 'Ctrl+C', copy: 'Ctrl+C',
cut: 'Ctrl+X', cut: 'Ctrl+X',
@ -49,11 +50,14 @@ const windowsAccelerator = Object.assign({
undo: 'Ctrl+Z', undo: 'Ctrl+Z',
zoomIn: 'Ctrl+=', zoomIn: 'Ctrl+=',
zoomOut: 'Ctrl+-', zoomOut: 'Ctrl+-',
}); },
};
const macAccelerator = Object.assign({ const macAccelerator = {
...{
zoomIn: 'CommandOrControl+Plus', zoomIn: 'CommandOrControl+Plus',
}); },
};
let { let {
minimizeOnClose, minimizeOnClose,

View File

@ -197,11 +197,11 @@ class Config {
* @param fields * @param fields
*/ */
public getConfigFields(fields: string[]): IConfig { public getConfigFields(fields: string[]): IConfig {
const configFields = { const configFields: IConfig = {
...this.getGlobalConfigFields(fields), ...this.getGlobalConfigFields(fields),
...this.getUserConfigFields(fields), ...this.getUserConfigFields(fields),
...this.getFilteredCloudConfigFields(fields), ...this.getFilteredCloudConfigFields(fields),
} as IConfig; };
logger.info( logger.info(
`config-handler: getting combined config values for the fields ${fields}`, `config-handler: getting combined config values for the fields ${fields}`,
configFields, configFields,
@ -380,7 +380,8 @@ class Config {
`config-handler: setting first time launch for build`, `config-handler: setting first time launch for build`,
buildNumber, buildNumber,
); );
return await this.updateUserConfig(filteredFields); await this.updateUserConfig(filteredFields);
return;
} }
await this.updateUserConfig({ await this.updateUserConfig({
buildNumber, buildNumber,

View File

@ -1,5 +1,4 @@
import * as electron from 'electron'; import { app, BrowserWindow, dialog } from 'electron';
import { app } from 'electron';
import { i18n } from '../common/i18n'; import { i18n } from '../common/i18n';
import { logger } from '../common/logger'; import { logger } from '../common/logger';
@ -7,10 +6,10 @@ import { CloudConfigDataTypes, config } from './config-handler';
import { ICustomBrowserWindow, windowHandler } from './window-handler'; import { ICustomBrowserWindow, windowHandler } from './window-handler';
import { windowExists } from './window-utils'; import { windowExists } from './window-utils';
let currentAuthURL; let currentAuthURL: string;
let tries = 0; let tries = 0;
electron.app.on('login', (event, webContents, request, authInfo, callback) => { app.on('login', (event, webContents, request, authInfo, callback) => {
event.preventDefault(); event.preventDefault();
// This check is to determine whether the request is for the same // This check is to determine whether the request is for the same
@ -25,7 +24,7 @@ electron.app.on('login', (event, webContents, request, authInfo, callback) => {
// name of the host to display // name of the host to display
const hostname = authInfo.host || authInfo.realm; const hostname = authInfo.host || authInfo.realm;
const browserWin: ICustomBrowserWindow = electron.BrowserWindow.fromWebContents( const browserWin: ICustomBrowserWindow = BrowserWindow.fromWebContents(
webContents, webContents,
) as ICustomBrowserWindow; ) as ICustomBrowserWindow;
@ -61,7 +60,7 @@ let ignoreAllCertErrors = false;
* Note: the dialog is synchronous so further processing is blocked until * Note: the dialog is synchronous so further processing is blocked until
* user provides a response. * user provides a response.
*/ */
electron.app.on( app.on(
'certificate-error', 'certificate-error',
async (event, webContents, url, error, _certificate, callback) => { async (event, webContents, url, error, _certificate, callback) => {
// TODO: Add logic verify custom certificate // TODO: Add logic verify custom certificate
@ -76,9 +75,9 @@ electron.app.on(
event.preventDefault(); event.preventDefault();
const browserWin = electron.BrowserWindow.fromWebContents(webContents); const browserWin = BrowserWindow.fromWebContents(webContents);
if (browserWin && windowExists(browserWin)) { if (browserWin && windowExists(browserWin)) {
const { response } = await electron.dialog.showMessageBox(browserWin, { const { response } = await dialog.showMessageBox(browserWin, {
type: 'warning', type: 'warning',
buttons: [i18n.t('Allow')(), i18n.t('Deny')(), i18n.t('Ignore All')()], buttons: [i18n.t('Allow')(), i18n.t('Deny')(), i18n.t('Ignore All')()],
defaultId: 1, defaultId: 1,
@ -125,7 +124,7 @@ export const showLoadFailure = async (
} }
if (showDialog) { if (showDialog) {
const { response } = await electron.dialog.showMessageBox(browserWindow, { const { response } = await dialog.showMessageBox(browserWindow, {
type: 'error', type: 'error',
buttons: [i18n.t('Reload')(), i18n.t('Ignore')()], buttons: [i18n.t('Reload')(), i18n.t('Ignore')()],
defaultId: 0, defaultId: 0,
@ -174,7 +173,7 @@ export const showNetworkConnectivityError = (
export const titleBarChangeDialog = async ( export const titleBarChangeDialog = async (
isNativeStyle: CloudConfigDataTypes, isNativeStyle: CloudConfigDataTypes,
) => { ) => {
const focusedWindow = electron.BrowserWindow.getFocusedWindow(); const focusedWindow = BrowserWindow.getFocusedWindow();
if (!focusedWindow || !windowExists(focusedWindow)) { if (!focusedWindow || !windowExists(focusedWindow)) {
return; return;
} }
@ -190,10 +189,7 @@ export const titleBarChangeDialog = async (
buttons: [i18n.t('Relaunch')(), i18n.t('Cancel')()], buttons: [i18n.t('Relaunch')(), i18n.t('Cancel')()],
cancelId: 1, cancelId: 1,
}; };
const { response } = await electron.dialog.showMessageBox( const { response } = await dialog.showMessageBox(focusedWindow, options);
focusedWindow,
options,
);
if (response === 0) { if (response === 0) {
logger.error(`test`, isNativeStyle); logger.error(`test`, isNativeStyle);
await config.updateUserConfig({ isCustomTitleBar: isNativeStyle }); await config.updateUserConfig({ isCustomTitleBar: isNativeStyle });
@ -207,7 +203,7 @@ export const titleBarChangeDialog = async (
* @param disableGpu * @param disableGpu
*/ */
export const gpuRestartDialog = async (disableGpu: boolean) => { export const gpuRestartDialog = async (disableGpu: boolean) => {
const focusedWindow = electron.BrowserWindow.getFocusedWindow(); const focusedWindow = BrowserWindow.getFocusedWindow();
if (!focusedWindow || !windowExists(focusedWindow)) { if (!focusedWindow || !windowExists(focusedWindow)) {
return; return;
} }
@ -220,10 +216,7 @@ export const gpuRestartDialog = async (disableGpu: boolean) => {
buttons: [i18n.t('Restart')(), i18n.t('Later')()], buttons: [i18n.t('Restart')(), i18n.t('Later')()],
cancelId: 1, cancelId: 1,
}; };
const { response } = await electron.dialog.showMessageBox( const { response } = await dialog.showMessageBox(focusedWindow, options);
focusedWindow,
options,
);
await config.updateUserConfig({ disableGpu }); await config.updateUserConfig({ disableGpu });
if (response === 0) { if (response === 0) {
app.relaunch(); app.relaunch();

View File

@ -1,6 +1,5 @@
import * as archiver from 'archiver'; import * as archiver from 'archiver';
import { app, BrowserWindow, dialog, shell } from 'electron'; import { app, BrowserWindow, crashReporter, dialog, shell } from 'electron';
import * as electron from 'electron';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
@ -185,7 +184,7 @@ export const exportLogs = (): void => {
*/ */
export const exportCrashDumps = (): void => { export const exportCrashDumps = (): void => {
const FILE_EXTENSIONS = isMac ? ['.dmp'] : ['.dmp', '.txt']; const FILE_EXTENSIONS = isMac ? ['.dmp'] : ['.dmp', '.txt'];
const crashesDirectory = (electron.crashReporter as any).getCrashesDirectory(); const crashesDirectory = (crashReporter as any).getCrashesDirectory();
const source = isMac ? crashesDirectory + '/completed' : crashesDirectory; const source = isMac ? crashesDirectory + '/completed' : crashesDirectory;
const focusedWindow = BrowserWindow.getFocusedWindow(); const focusedWindow = BrowserWindow.getFocusedWindow();
@ -195,7 +194,7 @@ export const exportCrashDumps = (): void => {
focusedWindow && focusedWindow &&
!focusedWindow.isDestroyed()) !focusedWindow.isDestroyed())
) { ) {
electron.dialog.showMessageBox(focusedWindow as BrowserWindow, { dialog.showMessageBox(focusedWindow as BrowserWindow, {
message: i18n.t('No crashes available to share')(), message: i18n.t('No crashes available to share')(),
title: i18n.t('Failed!')(), title: i18n.t('Failed!')(),
type: 'error', type: 'error',
@ -207,16 +206,15 @@ export const exportCrashDumps = (): void => {
isMac || isLinux ? '/crashes_symphony_' : '\\crashes_symphony_'; isMac || isLinux ? '/crashes_symphony_' : '\\crashes_symphony_';
const timestamp = new Date().getTime(); const timestamp = new Date().getTime();
const destination = const destination = app.getPath('downloads') + destPath + timestamp + '.zip';
electron.app.getPath('downloads') + destPath + timestamp + '.zip';
generateArchiveForDirectory(source, destination, FILE_EXTENSIONS, []) generateArchiveForDirectory(source, destination, FILE_EXTENSIONS, [])
.then(() => { .then(() => {
electron.shell.showItemInFolder(destination); shell.showItemInFolder(destination);
}) })
.catch((err) => { .catch((err) => {
if (focusedWindow && !focusedWindow.isDestroyed()) { if (focusedWindow && !focusedWindow.isDestroyed()) {
electron.dialog.showMessageBox(focusedWindow, { dialog.showMessageBox(focusedWindow, {
message: `${i18n.t( message: `${i18n.t(
'Unable to generate crash reports due to ', 'Unable to generate crash reports due to ',
)()} ${err}`, )()} ${err}`,

View File

@ -212,17 +212,17 @@ class ScreenSnippet {
private execCmd( private execCmd(
captureUtil: string, captureUtil: string,
captureUtilArgs: ReadonlyArray<string>, captureUtilArgs: ReadonlyArray<string>,
): Promise<ChildProcess> { ): Promise<void> {
logger.info( logger.info(
`screen-snippet-handlers: execCmd ${captureUtil} ${captureUtilArgs}`, `screen-snippet-handlers: execCmd ${captureUtil} ${captureUtilArgs}`,
); );
return new Promise<ChildProcess>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
return (this.child = execFile( return (this.child = execFile(
captureUtil, captureUtil,
captureUtilArgs, captureUtilArgs,
(error: ExecException | null) => { (error: ExecException | null) => {
if (error && error.killed) { if (error && error.killed) {
// processs was killed, just resolve with no data. // process was killed, just resolve with no data.
return reject(error); return reject(error);
} }
resolve(); resolve();

View File

@ -181,13 +181,11 @@ class VersionHandler {
logger.info('version-handler: hostname: ' + hostname); logger.info('version-handler: hostname: ' + hostname);
/* Get SFE version */ /* Get SFE version */
let urlSfeVersion; let urlSfeVersion: string;
if (mainUrl?.includes('/client-bff/')) { if (mainUrl?.includes('/client-bff/')) {
if (mainUrl?.includes('/client-bff/daily/')) { urlSfeVersion = mainUrl?.includes('/client-bff/daily/')
urlSfeVersion = `${protocol}//${hostname}/client-bff/daily/version.json`; ? `${protocol}//${hostname}/client-bff/daily/version.json`
} else { : `${protocol}//${hostname}/client-bff/version.json`;
urlSfeVersion = `${protocol}//${hostname}/client-bff/version.json`;
}
this.versionInfo.sfeClientType = '2.0'; this.versionInfo.sfeClientType = '2.0';
} else { } else {
urlSfeVersion = `${protocol}//${hostname}/client/version.json`; urlSfeVersion = `${protocol}//${hostname}/client/version.json`;

View File

@ -40,13 +40,14 @@ const saveWindowSettings = async (): Promise<void> => {
mainWindow && mainWindow &&
windowExists(mainWindow) windowExists(mainWindow)
) { ) {
mainWindow.webContents.send('boundsChange', { const boundsChange: IBoundsChange = {
x, x,
y, y,
width, width,
height, height,
windowName: browserWindow.winName, windowName: browserWindow.winName,
} as IBoundsChange); };
mainWindow.webContents.send('boundsChange', boundsChange);
} }
// Update the config file // Update the config file
@ -126,13 +127,14 @@ export const sendInitialBoundChanges = (childWindow: BrowserWindow): void => {
} }
const { x, y, width, height } = childWindow.getBounds(); const { x, y, width, height } = childWindow.getBounds();
const windowName = (childWindow as ICustomBrowserWindow).winName; const windowName = (childWindow as ICustomBrowserWindow).winName;
mainWindow.webContents.send('boundsChange', { const boundsChange: IBoundsChange = {
x, x,
y, y,
width, width,
height, height,
windowName, windowName,
} as IBoundsChange); };
mainWindow.webContents.send('boundsChange', boundsChange);
logger.info( logger.info(
`window-actions: Initial bounds sent for ${ `window-actions: Initial bounds sent for ${
(childWindow as ICustomBrowserWindow).winName (childWindow as ICustomBrowserWindow).winName

View File

@ -1,13 +1,15 @@
import { ChildProcess, ExecException, execFile } from 'child_process'; import { ChildProcess, ExecException, execFile } from 'child_process';
import * as electron from 'electron';
import { import {
app, app,
BrowserWindow, BrowserWindow,
BrowserWindowConstructorOptions, BrowserWindowConstructorOptions,
crashReporter, crashReporter,
DesktopCapturerSource, DesktopCapturerSource,
dialog,
globalShortcut, globalShortcut,
ipcMain, ipcMain,
screen,
shell,
} from 'electron'; } from 'electron';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
@ -556,7 +558,7 @@ export class WindowHandler {
return; return;
} }
logger.info(`window-handler: main window crashed!`); logger.info(`window-handler: main window crashed!`);
const { response } = await electron.dialog.showMessageBox({ const { response } = await dialog.showMessageBox({
type: 'error', type: 'error',
title: i18n.t('Renderer Process Crashed')(), title: i18n.t('Renderer Process Crashed')(),
message: i18n.t( message: i18n.t(
@ -843,9 +845,7 @@ export class WindowHandler {
*/ */
public moveWindow(windowToMove: BrowserWindow, fixedYPosition?: number) { public moveWindow(windowToMove: BrowserWindow, fixedYPosition?: number) {
if (this.mainWindow && windowExists(this.mainWindow)) { if (this.mainWindow && windowExists(this.mainWindow)) {
const display = electron.screen.getDisplayMatching( const display = screen.getDisplayMatching(this.mainWindow.getBounds());
this.mainWindow.getBounds(),
);
logger.info( logger.info(
'window-handler: moveWindow, display: ' + 'window-handler: moveWindow, display: ' +
@ -951,15 +951,11 @@ export class WindowHandler {
if (this.url && this.url.startsWith('https://corporate.symphony.com')) { if (this.url && this.url.startsWith('https://corporate.symphony.com')) {
const manaPath = 'client-bff'; const manaPath = 'client-bff';
const daily = 'daily'; const daily = 'daily';
if (this.url.includes(manaPath)) { client = this.url.includes(manaPath)
if (this.url.includes(daily)) { ? this.url.includes(daily)
client = 'Symphony 2.0 - Daily'; ? 'Symphony 2.0 - Daily'
} else { : 'Symphony 2.0'
client = 'Symphony 2.0'; : 'Symphony Classic';
}
} else {
client = 'Symphony Classic';
}
} }
const ABOUT_SYMPHONY_NAMESPACE = 'AboutSymphony'; const ABOUT_SYMPHONY_NAMESPACE = 'AboutSymphony';
const versionLocalised = i18n.t('Version', ABOUT_SYMPHONY_NAMESPACE)(); const versionLocalised = i18n.t('Version', ABOUT_SYMPHONY_NAMESPACE)();
@ -1013,7 +1009,7 @@ export class WindowHandler {
}), }),
); );
const allDisplays = electron.screen.getAllDisplays(); const allDisplays = screen.getAllDisplays();
logger.info( logger.info(
'window-handler, createSnippingToolWindow: User has these displays: ' + 'window-handler, createSnippingToolWindow: User has these displays: ' +
JSON.stringify(allDisplays), JSON.stringify(allDisplays),
@ -1031,9 +1027,7 @@ export class WindowHandler {
const BUTTON_BAR_BOTTOM_HEIGHT = 72; const BUTTON_BAR_BOTTOM_HEIGHT = 72;
const BUTTON_BARS_HEIGHT = BUTTON_BAR_TOP_HEIGHT + BUTTON_BAR_BOTTOM_HEIGHT; const BUTTON_BARS_HEIGHT = BUTTON_BAR_TOP_HEIGHT + BUTTON_BAR_BOTTOM_HEIGHT;
const display = electron.screen.getDisplayMatching( const display = screen.getDisplayMatching(this.mainWindow.getBounds());
this.mainWindow.getBounds(),
);
const workAreaSize = display.workAreaSize; const workAreaSize = display.workAreaSize;
const maxToolHeight = Math.floor( const maxToolHeight = Math.floor(
calculatePercentage(workAreaSize.height, 90), calculatePercentage(workAreaSize.height, 90),
@ -1191,7 +1185,7 @@ export class WindowHandler {
* *
*/ */
public drawScreenShareIndicatorFrame(source) { public drawScreenShareIndicatorFrame(source) {
const displays = electron.screen.getAllDisplays(); const displays = screen.getAllDisplays();
logger.info('window-utils: displays.length: ' + displays.length); logger.info('window-utils: displays.length: ' + displays.length);
for (let i = 0, len = displays.length; i < len; i++) { for (let i = 0, len = displays.length; i < len; i++) {
logger.info( logger.info(
@ -1443,7 +1437,7 @@ export class WindowHandler {
) { ) {
let screens: Electron.Display[] = []; let screens: Electron.Display[] = [];
if (app.isReady()) { if (app.isReady()) {
screens = electron.screen.getAllDisplays(); screens = screen.getAllDisplays();
} }
const { position, display } = config.getConfigFields([ const { position, display } = config.getConfigFields([
'notificationSettings', 'notificationSettings',
@ -1502,10 +1496,10 @@ export class WindowHandler {
): void { ): void {
const indicatorScreen = const indicatorScreen =
(displayId && (displayId &&
electron.screen screen
.getAllDisplays() .getAllDisplays()
.filter((d) => displayId.includes(d.id.toString()))[0]) || .filter((d) => displayId.includes(d.id.toString()))[0]) ||
electron.screen.getPrimaryDisplay(); screen.getPrimaryDisplay();
const topPositionOfIndicatorScreen = 16; const topPositionOfIndicatorScreen = 16;
@ -1538,10 +1532,13 @@ export class WindowHandler {
...{ winKey: streamId }, ...{ winKey: streamId },
}; };
if (opts.width && opts.height) { if (opts.width && opts.height) {
opts = Object.assign({}, opts, { opts = {
...opts,
...{
x: screenRect.x + Math.round((screenRect.width - opts.width) / 2), x: screenRect.x + Math.round((screenRect.width - opts.width) / 2),
y: screenRect.y + topPositionOfIndicatorScreen, y: screenRect.y + topPositionOfIndicatorScreen,
}); },
};
} }
logger.info( logger.info(
@ -1550,7 +1547,7 @@ export class WindowHandler {
); );
if (displayId !== '') { if (displayId !== '') {
if (isLinux) { if (isLinux) {
const displays = electron.screen.getAllDisplays(); const displays = screen.getAllDisplays();
displays.forEach((element) => { displays.forEach((element) => {
logger.info( logger.info(
'window-handler: element.id.toString(): ' + element.id.toString(), 'window-handler: element.id.toString(): ' + element.id.toString(),
@ -1688,7 +1685,7 @@ export class WindowHandler {
*/ */
public openUrlInDefaultBrowser(urlToOpen) { public openUrlInDefaultBrowser(urlToOpen) {
if (urlToOpen) { if (urlToOpen) {
electron.shell.openExternal(urlToOpen); shell.openExternal(urlToOpen);
logger.info( logger.info(
`window-handler: opened url ${urlToOpen} in the default browser!`, `window-handler: opened url ${urlToOpen} in the default browser!`,
); );
@ -1720,12 +1717,9 @@ export class WindowHandler {
* @param util {string} * @param util {string}
* @param utilArgs {ReadonlyArray<string>} * @param utilArgs {ReadonlyArray<string>}
*/ */
public execCmd( public execCmd(util: string, utilArgs: ReadonlyArray<string>): Promise<void> {
util: string,
utilArgs: ReadonlyArray<string>,
): Promise<ChildProcess> {
logger.info(`window handler: execCmd: util: ${util} utilArgs: ${utilArgs}`); logger.info(`window handler: execCmd: util: ${util} utilArgs: ${utilArgs}`);
return new Promise<ChildProcess>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
return execFile(util, utilArgs, (error: ExecException | null) => { return execFile(util, utilArgs, (error: ExecException | null) => {
if (error) { if (error) {
logger.info(`window handler: execCmd: error: ${error}`); logger.info(`window handler: execCmd: error: ${error}`);
@ -2029,12 +2023,9 @@ export class WindowHandler {
cancelId: 0, cancelId: 0,
}; };
const { response } = await electron.dialog.showMessageBox( const { response } = await dialog.showMessageBox(browserWindow, options);
browserWindow,
options,
);
if (response === 0) { if (response === 0) {
electron.app.exit(); app.exit();
} }
} }

View File

@ -1,5 +1,12 @@
import * as electron from 'electron'; import {
import { app, BrowserWindow, nativeImage } from 'electron'; app,
BrowserWindow,
dialog,
nativeImage,
screen,
shell,
} from 'electron';
import electron = require('electron');
import fetch from 'electron-fetch'; import fetch from 'electron-fetch';
import * as filesize from 'filesize'; import * as filesize from 'filesize';
import * as fs from 'fs'; import * as fs from 'fs';
@ -88,7 +95,7 @@ export const preventWindowNavigation = (
if (!isValid) { if (!isValid) {
e.preventDefault(); e.preventDefault();
if (browserWindow && windowExists(browserWindow)) { if (browserWindow && windowExists(browserWindow)) {
const response = await electron.dialog.showMessageBox(browserWindow, { const response = await dialog.showMessageBox(browserWindow, {
type: 'warning', type: 'warning',
buttons: ['OK'], buttons: ['OK'],
title: i18n.t('Not Allowed')(), title: i18n.t('Not Allowed')(),
@ -352,7 +359,7 @@ export const getBounds = (
if (!winPos || !winPos.x || !winPos.y || !winPos.width || !winPos.height) { if (!winPos || !winPos.x || !winPos.y || !winPos.width || !winPos.height) {
return { width: defaultWidth, height: defaultHeight }; return { width: defaultWidth, height: defaultHeight };
} }
const displays = electron.screen.getAllDisplays(); const displays = screen.getAllDisplays();
for (let i = 0, len = displays.length; i < len; i++) { for (let i = 0, len = displays.length; i < len; i++) {
const bounds = displays[i].bounds; const bounds = displays[i].bounds;
@ -368,9 +375,7 @@ export const getBounds = (
} }
// Fit in the middle of immediate display // Fit in the middle of immediate display
const display = electron.screen.getDisplayMatching( const display = screen.getDisplayMatching(winPos as electron.Rectangle);
winPos as electron.Rectangle,
);
if (display) { if (display) {
// Check that defaultWidth fits // Check that defaultWidth fits
@ -402,7 +407,7 @@ export const getBounds = (
* @param filePath * @param filePath
*/ */
export const downloadManagerAction = async (type, filePath): Promise<void> => { export const downloadManagerAction = async (type, filePath): Promise<void> => {
const focusedWindow = electron.BrowserWindow.getFocusedWindow(); const focusedWindow = BrowserWindow.getFocusedWindow();
const message = i18n.t( const message = i18n.t(
'The file you are trying to open cannot be found in the specified path.', 'The file you are trying to open cannot be found in the specified path.',
DOWNLOAD_MANAGER_NAMESPACE, DOWNLOAD_MANAGER_NAMESPACE,
@ -417,14 +422,14 @@ export const downloadManagerAction = async (type, filePath): Promise<void> => {
const fileExists = fs.existsSync(`${filePath}`); const fileExists = fs.existsSync(`${filePath}`);
let openFileResponse; let openFileResponse;
if (fileExists) { if (fileExists) {
openFileResponse = await electron.shell.openPath(filePath); openFileResponse = await shell.openPath(filePath);
} }
if ( if (
openFileResponse !== '' && openFileResponse !== '' &&
focusedWindow && focusedWindow &&
!focusedWindow.isDestroyed() !focusedWindow.isDestroyed()
) { ) {
electron.dialog.showMessageBox(focusedWindow, { dialog.showMessageBox(focusedWindow, {
message, message,
title, title,
type: 'error', type: 'error',
@ -433,9 +438,9 @@ export const downloadManagerAction = async (type, filePath): Promise<void> => {
return; return;
} }
if (fs.existsSync(filePath)) { if (fs.existsSync(filePath)) {
electron.shell.showItemInFolder(filePath); shell.showItemInFolder(filePath);
} else { } else {
electron.dialog.showMessageBox(focusedWindow, { dialog.showMessageBox(focusedWindow, {
message, message,
title, title,
type: 'error', type: 'error',
@ -569,7 +574,8 @@ export const injectStyles = async (
}); });
} }
return await readAndInsertCSS(mainWindow); await readAndInsertCSS(mainWindow);
return;
}; };
/** /**

View File

@ -381,6 +381,8 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
* @param state * @param state
*/ */
private updateState(state: Partial<IState>) { private updateState(state: Partial<IState>) {
this.setState((s) => Object.assign(s, state)); this.setState((s) => {
return { ...s, ...state };
});
} }
} }

View File

@ -151,9 +151,12 @@ export const getSource = async (
const updatedSources = sources const updatedSources = sources
.filter((source) => source.name !== NOTIFICATION_WINDOW_TITLE) .filter((source) => source.name !== NOTIFICATION_WINDOW_TITLE)
.map((source) => { .map((source) => {
return Object.assign({}, source, { return {
...source,
...{
thumbnail: source.thumbnail.toDataURL(), thumbnail: source.thumbnail.toDataURL(),
}); },
};
}); });
ipcRenderer.send(apiName.symphonyApi, { ipcRenderer.send(apiName.symphonyApi, {

View File

@ -1,6 +1,5 @@
import * as asyncMap from 'async.map'; import * as asyncMap from 'async.map';
import { app } from 'electron'; import { app, screen } from 'electron';
import * as electron from 'electron';
import { windowExists } from '../app/window-utils'; import { windowExists } from '../app/window-utils';
import { isLinux, isMac } from '../common/env'; import { isLinux, isMac } from '../common/env';
@ -45,9 +44,9 @@ export default class NotificationHandler {
this.setupNotificationPosition(); this.setupNotificationPosition();
app.once('ready', () => { app.once('ready', () => {
electron.screen.on('display-added', this.eventHandlers.onSetup); screen.on('display-added', this.eventHandlers.onSetup);
electron.screen.on('display-removed', this.eventHandlers.onSetup); screen.on('display-removed', this.eventHandlers.onSetup);
electron.screen.on('display-metrics-changed', this.eventHandlers.onSetup); screen.on('display-metrics-changed', this.eventHandlers.onSetup);
}); });
} }
@ -77,7 +76,7 @@ export default class NotificationHandler {
return; return;
} }
const screens = electron.screen.getAllDisplays(); const screens = screen.getAllDisplays();
if (screens && screens.length >= 0) { if (screens && screens.length >= 0) {
this.externalDisplay = screens.find((screen) => { this.externalDisplay = screens.find((screen) => {
const screenId = screen.id.toString(); const screenId = screen.id.toString();
@ -85,7 +84,7 @@ export default class NotificationHandler {
}); });
} }
const display = this.externalDisplay || electron.screen.getPrimaryDisplay(); const display = this.externalDisplay || screen.getPrimaryDisplay();
this.settings.corner.x = display.workArea.x; this.settings.corner.x = display.workArea.x;
this.settings.corner.y = display.workArea.y; this.settings.corner.y = display.workArea.y;

View File

@ -196,7 +196,8 @@ class Notification extends NotificationHandler {
event.preventDefault(); event.preventDefault();
}); });
return await this.didFinishLoad(notificationWindow, data); await this.didFinishLoad(notificationWindow, data);
return;
} }
/** /**
@ -410,11 +411,11 @@ class Notification extends NotificationHandler {
public async cleanUp(): Promise<void> { public async cleanUp(): Promise<void> {
animationQueue.clear(); animationQueue.clear();
this.notificationQueue = []; this.notificationQueue = [];
const activeNotificationWindows = Object.assign( const activeNotificationWindows = {
[], ...[],
this.activeNotifications, ...this.activeNotifications,
); };
const inactiveNotificationWindows = Object.assign([], this.inactiveWindows); const inactiveNotificationWindows = { ...[], ...this.inactiveWindows };
for (const activeWindow of activeNotificationWindows) { for (const activeWindow of activeNotificationWindows) {
if (activeWindow && windowExists(activeWindow)) { if (activeWindow && windowExists(activeWindow)) {
await this.hideNotification( await this.hideNotification(

View File

@ -1,5 +1,5 @@
{ {
"extends": ["tslint:recommended", "tslint-config-prettier"], "extends": ["tslint:latest", "tslint-config-prettier"],
"linterOptions": { "linterOptions": {
"exclude": ["**/*.json"] "exclude": ["**/*.json"]
}, },
@ -24,13 +24,15 @@
"no-empty": true, "no-empty": true,
"no-unused-expression": true, "no-unused-expression": true,
"no-use-before-declare": true, "no-use-before-declare": true,
"no-implicit-dependencies": [true, "dev", "optional"],
"no-object-literal-type-assertion": false,
"no-var-requires": true, "no-var-requires": true,
"only-arrow-functions": true, "only-arrow-functions": true,
"object-literal-sort-keys": false, "object-literal-sort-keys": false,
"no-console": [true, "log", "error"], "no-console": [true, "log", "error"],
"one-line": [true, "check-else", "check-whitespace", "check-open-brace"], "one-line": [true, "check-else", "check-whitespace", "check-open-brace"],
"quotemark": [true, "single", "avoid-escape"], "quotemark": [true, "single", "avoid-escape"],
"semicolon": [true, "always"], "semicolon": [true, "always", "ignore-bound-class-methods"],
"typedef-whitespace": [ "typedef-whitespace": [
true, true,
{ {