mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
chore: format the problematic files
This commit is contained in:
parent
2c4773d4e5
commit
396dc4e950
@ -189,7 +189,7 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
"pre-commit": "pretty-quick --staged && npm run lint"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ export const stopApplication = async (
|
||||
if (!application || !application.isRunning()) {
|
||||
return;
|
||||
}
|
||||
return await application.stop();
|
||||
await application.stop();
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as electron from 'electron';
|
||||
import { app } from 'electron';
|
||||
import { app, powerMonitor } from 'electron';
|
||||
import Timer = NodeJS.Timer;
|
||||
|
||||
import { logger } from '../common/logger';
|
||||
@ -44,7 +43,7 @@ class ActivityDetection {
|
||||
if (app.isReady()) {
|
||||
logger.info(`activity-detection: Starting activity monitor`);
|
||||
this.queryInterval = setInterval(() => {
|
||||
const idleTime = electron.powerMonitor.getSystemIdleTime();
|
||||
const idleTime = powerMonitor.getSystemIdleTime();
|
||||
this.activity(idleTime);
|
||||
}, this.idleThreshold);
|
||||
}
|
||||
@ -81,7 +80,7 @@ class ActivityDetection {
|
||||
// when user goes inactive
|
||||
this.timer = setInterval(() => {
|
||||
if (app.isReady()) {
|
||||
const activeTime = electron.powerMonitor.getSystemIdleTime();
|
||||
const activeTime = powerMonitor.getSystemIdleTime();
|
||||
this.activity(activeTime);
|
||||
}
|
||||
}, 1000);
|
||||
|
@ -32,28 +32,32 @@ export const menuSections = {
|
||||
edit: 'edit',
|
||||
view: 'view',
|
||||
window: 'window',
|
||||
help: 'help', // tslint:disable-line
|
||||
help: 'help',
|
||||
};
|
||||
|
||||
const windowsAccelerator = Object.assign({
|
||||
close: 'Ctrl+W',
|
||||
copy: 'Ctrl+C',
|
||||
cut: 'Ctrl+X',
|
||||
minimize: 'Ctrl+M',
|
||||
paste: 'Ctrl+V',
|
||||
pasteAndMatchStyle: 'Ctrl+Shift+V',
|
||||
redo: 'Ctrl+Y',
|
||||
resetZoom: 'Ctrl+0',
|
||||
selectAll: 'Ctrl+A',
|
||||
togglefullscreen: 'F11',
|
||||
undo: 'Ctrl+Z',
|
||||
zoomIn: 'Ctrl+=',
|
||||
zoomOut: 'Ctrl+-',
|
||||
});
|
||||
const windowsAccelerator = {
|
||||
...{
|
||||
close: 'Ctrl+W',
|
||||
copy: 'Ctrl+C',
|
||||
cut: 'Ctrl+X',
|
||||
minimize: 'Ctrl+M',
|
||||
paste: 'Ctrl+V',
|
||||
pasteAndMatchStyle: 'Ctrl+Shift+V',
|
||||
redo: 'Ctrl+Y',
|
||||
resetZoom: 'Ctrl+0',
|
||||
selectAll: 'Ctrl+A',
|
||||
togglefullscreen: 'F11',
|
||||
undo: 'Ctrl+Z',
|
||||
zoomIn: 'Ctrl+=',
|
||||
zoomOut: 'Ctrl+-',
|
||||
},
|
||||
};
|
||||
|
||||
const macAccelerator = Object.assign({
|
||||
zoomIn: 'CommandOrControl+Plus',
|
||||
});
|
||||
const macAccelerator = {
|
||||
...{
|
||||
zoomIn: 'CommandOrControl+Plus',
|
||||
},
|
||||
};
|
||||
|
||||
let {
|
||||
minimizeOnClose,
|
||||
|
@ -197,11 +197,11 @@ class Config {
|
||||
* @param fields
|
||||
*/
|
||||
public getConfigFields(fields: string[]): IConfig {
|
||||
const configFields = {
|
||||
const configFields: IConfig = {
|
||||
...this.getGlobalConfigFields(fields),
|
||||
...this.getUserConfigFields(fields),
|
||||
...this.getFilteredCloudConfigFields(fields),
|
||||
} as IConfig;
|
||||
};
|
||||
logger.info(
|
||||
`config-handler: getting combined config values for the fields ${fields}`,
|
||||
configFields,
|
||||
@ -380,7 +380,8 @@ class Config {
|
||||
`config-handler: setting first time launch for build`,
|
||||
buildNumber,
|
||||
);
|
||||
return await this.updateUserConfig(filteredFields);
|
||||
await this.updateUserConfig(filteredFields);
|
||||
return;
|
||||
}
|
||||
await this.updateUserConfig({
|
||||
buildNumber,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as electron from 'electron';
|
||||
import { app } from 'electron';
|
||||
import { app, BrowserWindow, dialog } from 'electron';
|
||||
|
||||
import { i18n } from '../common/i18n';
|
||||
import { logger } from '../common/logger';
|
||||
@ -7,10 +6,10 @@ import { CloudConfigDataTypes, config } from './config-handler';
|
||||
import { ICustomBrowserWindow, windowHandler } from './window-handler';
|
||||
import { windowExists } from './window-utils';
|
||||
|
||||
let currentAuthURL;
|
||||
let currentAuthURL: string;
|
||||
let tries = 0;
|
||||
|
||||
electron.app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||
app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||
event.preventDefault();
|
||||
|
||||
// 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
|
||||
const hostname = authInfo.host || authInfo.realm;
|
||||
const browserWin: ICustomBrowserWindow = electron.BrowserWindow.fromWebContents(
|
||||
const browserWin: ICustomBrowserWindow = BrowserWindow.fromWebContents(
|
||||
webContents,
|
||||
) as ICustomBrowserWindow;
|
||||
|
||||
@ -61,7 +60,7 @@ let ignoreAllCertErrors = false;
|
||||
* Note: the dialog is synchronous so further processing is blocked until
|
||||
* user provides a response.
|
||||
*/
|
||||
electron.app.on(
|
||||
app.on(
|
||||
'certificate-error',
|
||||
async (event, webContents, url, error, _certificate, callback) => {
|
||||
// TODO: Add logic verify custom certificate
|
||||
@ -76,9 +75,9 @@ electron.app.on(
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const browserWin = electron.BrowserWindow.fromWebContents(webContents);
|
||||
const browserWin = BrowserWindow.fromWebContents(webContents);
|
||||
if (browserWin && windowExists(browserWin)) {
|
||||
const { response } = await electron.dialog.showMessageBox(browserWin, {
|
||||
const { response } = await dialog.showMessageBox(browserWin, {
|
||||
type: 'warning',
|
||||
buttons: [i18n.t('Allow')(), i18n.t('Deny')(), i18n.t('Ignore All')()],
|
||||
defaultId: 1,
|
||||
@ -125,7 +124,7 @@ export const showLoadFailure = async (
|
||||
}
|
||||
|
||||
if (showDialog) {
|
||||
const { response } = await electron.dialog.showMessageBox(browserWindow, {
|
||||
const { response } = await dialog.showMessageBox(browserWindow, {
|
||||
type: 'error',
|
||||
buttons: [i18n.t('Reload')(), i18n.t('Ignore')()],
|
||||
defaultId: 0,
|
||||
@ -174,7 +173,7 @@ export const showNetworkConnectivityError = (
|
||||
export const titleBarChangeDialog = async (
|
||||
isNativeStyle: CloudConfigDataTypes,
|
||||
) => {
|
||||
const focusedWindow = electron.BrowserWindow.getFocusedWindow();
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
if (!focusedWindow || !windowExists(focusedWindow)) {
|
||||
return;
|
||||
}
|
||||
@ -190,10 +189,7 @@ export const titleBarChangeDialog = async (
|
||||
buttons: [i18n.t('Relaunch')(), i18n.t('Cancel')()],
|
||||
cancelId: 1,
|
||||
};
|
||||
const { response } = await electron.dialog.showMessageBox(
|
||||
focusedWindow,
|
||||
options,
|
||||
);
|
||||
const { response } = await dialog.showMessageBox(focusedWindow, options);
|
||||
if (response === 0) {
|
||||
logger.error(`test`, isNativeStyle);
|
||||
await config.updateUserConfig({ isCustomTitleBar: isNativeStyle });
|
||||
@ -207,7 +203,7 @@ export const titleBarChangeDialog = async (
|
||||
* @param disableGpu
|
||||
*/
|
||||
export const gpuRestartDialog = async (disableGpu: boolean) => {
|
||||
const focusedWindow = electron.BrowserWindow.getFocusedWindow();
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
if (!focusedWindow || !windowExists(focusedWindow)) {
|
||||
return;
|
||||
}
|
||||
@ -220,10 +216,7 @@ export const gpuRestartDialog = async (disableGpu: boolean) => {
|
||||
buttons: [i18n.t('Restart')(), i18n.t('Later')()],
|
||||
cancelId: 1,
|
||||
};
|
||||
const { response } = await electron.dialog.showMessageBox(
|
||||
focusedWindow,
|
||||
options,
|
||||
);
|
||||
const { response } = await dialog.showMessageBox(focusedWindow, options);
|
||||
await config.updateUserConfig({ disableGpu });
|
||||
if (response === 0) {
|
||||
app.relaunch();
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as archiver from 'archiver';
|
||||
import { app, BrowserWindow, dialog, shell } from 'electron';
|
||||
import * as electron from 'electron';
|
||||
import { app, BrowserWindow, crashReporter, dialog, shell } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@ -185,7 +184,7 @@ export const exportLogs = (): void => {
|
||||
*/
|
||||
export const exportCrashDumps = (): void => {
|
||||
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 focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
|
||||
@ -195,7 +194,7 @@ export const exportCrashDumps = (): void => {
|
||||
focusedWindow &&
|
||||
!focusedWindow.isDestroyed())
|
||||
) {
|
||||
electron.dialog.showMessageBox(focusedWindow as BrowserWindow, {
|
||||
dialog.showMessageBox(focusedWindow as BrowserWindow, {
|
||||
message: i18n.t('No crashes available to share')(),
|
||||
title: i18n.t('Failed!')(),
|
||||
type: 'error',
|
||||
@ -207,16 +206,15 @@ export const exportCrashDumps = (): void => {
|
||||
isMac || isLinux ? '/crashes_symphony_' : '\\crashes_symphony_';
|
||||
const timestamp = new Date().getTime();
|
||||
|
||||
const destination =
|
||||
electron.app.getPath('downloads') + destPath + timestamp + '.zip';
|
||||
const destination = app.getPath('downloads') + destPath + timestamp + '.zip';
|
||||
|
||||
generateArchiveForDirectory(source, destination, FILE_EXTENSIONS, [])
|
||||
.then(() => {
|
||||
electron.shell.showItemInFolder(destination);
|
||||
shell.showItemInFolder(destination);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (focusedWindow && !focusedWindow.isDestroyed()) {
|
||||
electron.dialog.showMessageBox(focusedWindow, {
|
||||
dialog.showMessageBox(focusedWindow, {
|
||||
message: `${i18n.t(
|
||||
'Unable to generate crash reports due to ',
|
||||
)()} ${err}`,
|
||||
|
@ -212,17 +212,17 @@ class ScreenSnippet {
|
||||
private execCmd(
|
||||
captureUtil: string,
|
||||
captureUtilArgs: ReadonlyArray<string>,
|
||||
): Promise<ChildProcess> {
|
||||
): Promise<void> {
|
||||
logger.info(
|
||||
`screen-snippet-handlers: execCmd ${captureUtil} ${captureUtilArgs}`,
|
||||
);
|
||||
return new Promise<ChildProcess>((resolve, reject) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
return (this.child = execFile(
|
||||
captureUtil,
|
||||
captureUtilArgs,
|
||||
(error: ExecException | null) => {
|
||||
if (error && error.killed) {
|
||||
// processs was killed, just resolve with no data.
|
||||
// process was killed, just resolve with no data.
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
|
@ -181,13 +181,11 @@ class VersionHandler {
|
||||
logger.info('version-handler: hostname: ' + hostname);
|
||||
|
||||
/* Get SFE version */
|
||||
let urlSfeVersion;
|
||||
let urlSfeVersion: string;
|
||||
if (mainUrl?.includes('/client-bff/')) {
|
||||
if (mainUrl?.includes('/client-bff/daily/')) {
|
||||
urlSfeVersion = `${protocol}//${hostname}/client-bff/daily/version.json`;
|
||||
} else {
|
||||
urlSfeVersion = `${protocol}//${hostname}/client-bff/version.json`;
|
||||
}
|
||||
urlSfeVersion = mainUrl?.includes('/client-bff/daily/')
|
||||
? `${protocol}//${hostname}/client-bff/daily/version.json`
|
||||
: `${protocol}//${hostname}/client-bff/version.json`;
|
||||
this.versionInfo.sfeClientType = '2.0';
|
||||
} else {
|
||||
urlSfeVersion = `${protocol}//${hostname}/client/version.json`;
|
||||
|
@ -40,13 +40,14 @@ const saveWindowSettings = async (): Promise<void> => {
|
||||
mainWindow &&
|
||||
windowExists(mainWindow)
|
||||
) {
|
||||
mainWindow.webContents.send('boundsChange', {
|
||||
const boundsChange: IBoundsChange = {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
windowName: browserWindow.winName,
|
||||
} as IBoundsChange);
|
||||
};
|
||||
mainWindow.webContents.send('boundsChange', boundsChange);
|
||||
}
|
||||
|
||||
// Update the config file
|
||||
@ -126,13 +127,14 @@ export const sendInitialBoundChanges = (childWindow: BrowserWindow): void => {
|
||||
}
|
||||
const { x, y, width, height } = childWindow.getBounds();
|
||||
const windowName = (childWindow as ICustomBrowserWindow).winName;
|
||||
mainWindow.webContents.send('boundsChange', {
|
||||
const boundsChange: IBoundsChange = {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
windowName,
|
||||
} as IBoundsChange);
|
||||
};
|
||||
mainWindow.webContents.send('boundsChange', boundsChange);
|
||||
logger.info(
|
||||
`window-actions: Initial bounds sent for ${
|
||||
(childWindow as ICustomBrowserWindow).winName
|
||||
|
@ -1,13 +1,15 @@
|
||||
import { ChildProcess, ExecException, execFile } from 'child_process';
|
||||
import * as electron from 'electron';
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
BrowserWindowConstructorOptions,
|
||||
crashReporter,
|
||||
DesktopCapturerSource,
|
||||
dialog,
|
||||
globalShortcut,
|
||||
ipcMain,
|
||||
screen,
|
||||
shell,
|
||||
} from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@ -556,7 +558,7 @@ export class WindowHandler {
|
||||
return;
|
||||
}
|
||||
logger.info(`window-handler: main window crashed!`);
|
||||
const { response } = await electron.dialog.showMessageBox({
|
||||
const { response } = await dialog.showMessageBox({
|
||||
type: 'error',
|
||||
title: i18n.t('Renderer Process Crashed')(),
|
||||
message: i18n.t(
|
||||
@ -843,9 +845,7 @@ export class WindowHandler {
|
||||
*/
|
||||
public moveWindow(windowToMove: BrowserWindow, fixedYPosition?: number) {
|
||||
if (this.mainWindow && windowExists(this.mainWindow)) {
|
||||
const display = electron.screen.getDisplayMatching(
|
||||
this.mainWindow.getBounds(),
|
||||
);
|
||||
const display = screen.getDisplayMatching(this.mainWindow.getBounds());
|
||||
|
||||
logger.info(
|
||||
'window-handler: moveWindow, display: ' +
|
||||
@ -951,15 +951,11 @@ export class WindowHandler {
|
||||
if (this.url && this.url.startsWith('https://corporate.symphony.com')) {
|
||||
const manaPath = 'client-bff';
|
||||
const daily = 'daily';
|
||||
if (this.url.includes(manaPath)) {
|
||||
if (this.url.includes(daily)) {
|
||||
client = 'Symphony 2.0 - Daily';
|
||||
} else {
|
||||
client = 'Symphony 2.0';
|
||||
}
|
||||
} else {
|
||||
client = 'Symphony Classic';
|
||||
}
|
||||
client = this.url.includes(manaPath)
|
||||
? this.url.includes(daily)
|
||||
? 'Symphony 2.0 - Daily'
|
||||
: 'Symphony 2.0'
|
||||
: 'Symphony Classic';
|
||||
}
|
||||
const ABOUT_SYMPHONY_NAMESPACE = 'AboutSymphony';
|
||||
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(
|
||||
'window-handler, createSnippingToolWindow: User has these displays: ' +
|
||||
JSON.stringify(allDisplays),
|
||||
@ -1031,9 +1027,7 @@ export class WindowHandler {
|
||||
const BUTTON_BAR_BOTTOM_HEIGHT = 72;
|
||||
const BUTTON_BARS_HEIGHT = BUTTON_BAR_TOP_HEIGHT + BUTTON_BAR_BOTTOM_HEIGHT;
|
||||
|
||||
const display = electron.screen.getDisplayMatching(
|
||||
this.mainWindow.getBounds(),
|
||||
);
|
||||
const display = screen.getDisplayMatching(this.mainWindow.getBounds());
|
||||
const workAreaSize = display.workAreaSize;
|
||||
const maxToolHeight = Math.floor(
|
||||
calculatePercentage(workAreaSize.height, 90),
|
||||
@ -1191,7 +1185,7 @@ export class WindowHandler {
|
||||
*
|
||||
*/
|
||||
public drawScreenShareIndicatorFrame(source) {
|
||||
const displays = electron.screen.getAllDisplays();
|
||||
const displays = screen.getAllDisplays();
|
||||
logger.info('window-utils: displays.length: ' + displays.length);
|
||||
for (let i = 0, len = displays.length; i < len; i++) {
|
||||
logger.info(
|
||||
@ -1443,7 +1437,7 @@ export class WindowHandler {
|
||||
) {
|
||||
let screens: Electron.Display[] = [];
|
||||
if (app.isReady()) {
|
||||
screens = electron.screen.getAllDisplays();
|
||||
screens = screen.getAllDisplays();
|
||||
}
|
||||
const { position, display } = config.getConfigFields([
|
||||
'notificationSettings',
|
||||
@ -1502,10 +1496,10 @@ export class WindowHandler {
|
||||
): void {
|
||||
const indicatorScreen =
|
||||
(displayId &&
|
||||
electron.screen
|
||||
screen
|
||||
.getAllDisplays()
|
||||
.filter((d) => displayId.includes(d.id.toString()))[0]) ||
|
||||
electron.screen.getPrimaryDisplay();
|
||||
screen.getPrimaryDisplay();
|
||||
|
||||
const topPositionOfIndicatorScreen = 16;
|
||||
|
||||
@ -1538,10 +1532,13 @@ export class WindowHandler {
|
||||
...{ winKey: streamId },
|
||||
};
|
||||
if (opts.width && opts.height) {
|
||||
opts = Object.assign({}, opts, {
|
||||
x: screenRect.x + Math.round((screenRect.width - opts.width) / 2),
|
||||
y: screenRect.y + topPositionOfIndicatorScreen,
|
||||
});
|
||||
opts = {
|
||||
...opts,
|
||||
...{
|
||||
x: screenRect.x + Math.round((screenRect.width - opts.width) / 2),
|
||||
y: screenRect.y + topPositionOfIndicatorScreen,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
logger.info(
|
||||
@ -1550,7 +1547,7 @@ export class WindowHandler {
|
||||
);
|
||||
if (displayId !== '') {
|
||||
if (isLinux) {
|
||||
const displays = electron.screen.getAllDisplays();
|
||||
const displays = screen.getAllDisplays();
|
||||
displays.forEach((element) => {
|
||||
logger.info(
|
||||
'window-handler: element.id.toString(): ' + element.id.toString(),
|
||||
@ -1688,7 +1685,7 @@ export class WindowHandler {
|
||||
*/
|
||||
public openUrlInDefaultBrowser(urlToOpen) {
|
||||
if (urlToOpen) {
|
||||
electron.shell.openExternal(urlToOpen);
|
||||
shell.openExternal(urlToOpen);
|
||||
logger.info(
|
||||
`window-handler: opened url ${urlToOpen} in the default browser!`,
|
||||
);
|
||||
@ -1720,12 +1717,9 @@ export class WindowHandler {
|
||||
* @param util {string}
|
||||
* @param utilArgs {ReadonlyArray<string>}
|
||||
*/
|
||||
public execCmd(
|
||||
util: string,
|
||||
utilArgs: ReadonlyArray<string>,
|
||||
): Promise<ChildProcess> {
|
||||
public execCmd(util: string, utilArgs: ReadonlyArray<string>): Promise<void> {
|
||||
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) => {
|
||||
if (error) {
|
||||
logger.info(`window handler: execCmd: error: ${error}`);
|
||||
@ -2029,12 +2023,9 @@ export class WindowHandler {
|
||||
cancelId: 0,
|
||||
};
|
||||
|
||||
const { response } = await electron.dialog.showMessageBox(
|
||||
browserWindow,
|
||||
options,
|
||||
);
|
||||
const { response } = await dialog.showMessageBox(browserWindow, options);
|
||||
if (response === 0) {
|
||||
electron.app.exit();
|
||||
app.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
import * as electron from 'electron';
|
||||
import { app, BrowserWindow, nativeImage } from 'electron';
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
dialog,
|
||||
nativeImage,
|
||||
screen,
|
||||
shell,
|
||||
} from 'electron';
|
||||
import electron = require('electron');
|
||||
import fetch from 'electron-fetch';
|
||||
import * as filesize from 'filesize';
|
||||
import * as fs from 'fs';
|
||||
@ -88,7 +95,7 @@ export const preventWindowNavigation = (
|
||||
if (!isValid) {
|
||||
e.preventDefault();
|
||||
if (browserWindow && windowExists(browserWindow)) {
|
||||
const response = await electron.dialog.showMessageBox(browserWindow, {
|
||||
const response = await dialog.showMessageBox(browserWindow, {
|
||||
type: 'warning',
|
||||
buttons: ['OK'],
|
||||
title: i18n.t('Not Allowed')(),
|
||||
@ -352,7 +359,7 @@ export const getBounds = (
|
||||
if (!winPos || !winPos.x || !winPos.y || !winPos.width || !winPos.height) {
|
||||
return { width: defaultWidth, height: defaultHeight };
|
||||
}
|
||||
const displays = electron.screen.getAllDisplays();
|
||||
const displays = screen.getAllDisplays();
|
||||
|
||||
for (let i = 0, len = displays.length; i < len; i++) {
|
||||
const bounds = displays[i].bounds;
|
||||
@ -368,9 +375,7 @@ export const getBounds = (
|
||||
}
|
||||
|
||||
// Fit in the middle of immediate display
|
||||
const display = electron.screen.getDisplayMatching(
|
||||
winPos as electron.Rectangle,
|
||||
);
|
||||
const display = screen.getDisplayMatching(winPos as electron.Rectangle);
|
||||
|
||||
if (display) {
|
||||
// Check that defaultWidth fits
|
||||
@ -402,7 +407,7 @@ export const getBounds = (
|
||||
* @param filePath
|
||||
*/
|
||||
export const downloadManagerAction = async (type, filePath): Promise<void> => {
|
||||
const focusedWindow = electron.BrowserWindow.getFocusedWindow();
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
const message = i18n.t(
|
||||
'The file you are trying to open cannot be found in the specified path.',
|
||||
DOWNLOAD_MANAGER_NAMESPACE,
|
||||
@ -417,14 +422,14 @@ export const downloadManagerAction = async (type, filePath): Promise<void> => {
|
||||
const fileExists = fs.existsSync(`${filePath}`);
|
||||
let openFileResponse;
|
||||
if (fileExists) {
|
||||
openFileResponse = await electron.shell.openPath(filePath);
|
||||
openFileResponse = await shell.openPath(filePath);
|
||||
}
|
||||
if (
|
||||
openFileResponse !== '' &&
|
||||
focusedWindow &&
|
||||
!focusedWindow.isDestroyed()
|
||||
) {
|
||||
electron.dialog.showMessageBox(focusedWindow, {
|
||||
dialog.showMessageBox(focusedWindow, {
|
||||
message,
|
||||
title,
|
||||
type: 'error',
|
||||
@ -433,9 +438,9 @@ export const downloadManagerAction = async (type, filePath): Promise<void> => {
|
||||
return;
|
||||
}
|
||||
if (fs.existsSync(filePath)) {
|
||||
electron.shell.showItemInFolder(filePath);
|
||||
shell.showItemInFolder(filePath);
|
||||
} else {
|
||||
electron.dialog.showMessageBox(focusedWindow, {
|
||||
dialog.showMessageBox(focusedWindow, {
|
||||
message,
|
||||
title,
|
||||
type: 'error',
|
||||
@ -569,7 +574,8 @@ export const injectStyles = async (
|
||||
});
|
||||
}
|
||||
|
||||
return await readAndInsertCSS(mainWindow);
|
||||
await readAndInsertCSS(mainWindow);
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -381,6 +381,8 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
||||
* @param state
|
||||
*/
|
||||
private updateState(state: Partial<IState>) {
|
||||
this.setState((s) => Object.assign(s, state));
|
||||
this.setState((s) => {
|
||||
return { ...s, ...state };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -151,9 +151,12 @@ export const getSource = async (
|
||||
const updatedSources = sources
|
||||
.filter((source) => source.name !== NOTIFICATION_WINDOW_TITLE)
|
||||
.map((source) => {
|
||||
return Object.assign({}, source, {
|
||||
thumbnail: source.thumbnail.toDataURL(),
|
||||
});
|
||||
return {
|
||||
...source,
|
||||
...{
|
||||
thumbnail: source.thumbnail.toDataURL(),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
ipcRenderer.send(apiName.symphonyApi, {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as asyncMap from 'async.map';
|
||||
import { app } from 'electron';
|
||||
import * as electron from 'electron';
|
||||
import { app, screen } from 'electron';
|
||||
|
||||
import { windowExists } from '../app/window-utils';
|
||||
import { isLinux, isMac } from '../common/env';
|
||||
@ -45,9 +44,9 @@ export default class NotificationHandler {
|
||||
this.setupNotificationPosition();
|
||||
|
||||
app.once('ready', () => {
|
||||
electron.screen.on('display-added', this.eventHandlers.onSetup);
|
||||
electron.screen.on('display-removed', this.eventHandlers.onSetup);
|
||||
electron.screen.on('display-metrics-changed', this.eventHandlers.onSetup);
|
||||
screen.on('display-added', this.eventHandlers.onSetup);
|
||||
screen.on('display-removed', this.eventHandlers.onSetup);
|
||||
screen.on('display-metrics-changed', this.eventHandlers.onSetup);
|
||||
});
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ export default class NotificationHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
const screens = electron.screen.getAllDisplays();
|
||||
const screens = screen.getAllDisplays();
|
||||
if (screens && screens.length >= 0) {
|
||||
this.externalDisplay = screens.find((screen) => {
|
||||
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.y = display.workArea.y;
|
||||
|
||||
|
@ -196,7 +196,8 @@ class Notification extends NotificationHandler {
|
||||
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> {
|
||||
animationQueue.clear();
|
||||
this.notificationQueue = [];
|
||||
const activeNotificationWindows = Object.assign(
|
||||
[],
|
||||
this.activeNotifications,
|
||||
);
|
||||
const inactiveNotificationWindows = Object.assign([], this.inactiveWindows);
|
||||
const activeNotificationWindows = {
|
||||
...[],
|
||||
...this.activeNotifications,
|
||||
};
|
||||
const inactiveNotificationWindows = { ...[], ...this.inactiveWindows };
|
||||
for (const activeWindow of activeNotificationWindows) {
|
||||
if (activeWindow && windowExists(activeWindow)) {
|
||||
await this.hideNotification(
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": ["tslint:recommended", "tslint-config-prettier"],
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"linterOptions": {
|
||||
"exclude": ["**/*.json"]
|
||||
},
|
||||
@ -24,13 +24,15 @@
|
||||
"no-empty": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-implicit-dependencies": [true, "dev", "optional"],
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-var-requires": true,
|
||||
"only-arrow-functions": true,
|
||||
"object-literal-sort-keys": false,
|
||||
"no-console": [true, "log", "error"],
|
||||
"one-line": [true, "check-else", "check-whitespace", "check-open-brace"],
|
||||
"quotemark": [true, "single", "avoid-escape"],
|
||||
"semicolon": [true, "always"],
|
||||
"semicolon": [true, "always", "ignore-bound-class-methods"],
|
||||
"typedef-whitespace": [
|
||||
true,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user