mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-791 (Fix pop-out memory leak and move spellchecker module to main process) (#519)
* ELECTRON-791 - Bump electron version to 3.0.5 and change spellchecker module * ELECTRON-791 - Remove AESDecryptGCM & AESEncryptGCM logs
This commit is contained in:
parent
1089fe62c1
commit
7fea8b0383
@ -106,7 +106,6 @@ const EncryptDecrypt = function (name, Base64IV, Base64AAD, Base64Key, Base64In)
|
||||
if (resultCode < 0) {
|
||||
log.send(logLevels.ERROR, `AESEncryptGCM, Failed to encrypt with exit code ${resultCode}`);
|
||||
}
|
||||
log.send(logLevels.INFO, `Output from AESEncryptGCM ${resultCode}`);
|
||||
const bufferArray = [OutPtr, Tag];
|
||||
return Buffer.concat(bufferArray).toString('base64');
|
||||
}
|
||||
@ -121,7 +120,6 @@ const EncryptDecrypt = function (name, Base64IV, Base64AAD, Base64Key, Base64In)
|
||||
if (resultCode < 0) {
|
||||
log.send(logLevels.ERROR, `AESDecryptGCM, Failed to decrypt with exit code ${resultCode}`);
|
||||
}
|
||||
log.send(logLevels.INFO, `Output from AESDecryptGCM ${resultCode}`);
|
||||
return OutPtr.toString('base64');
|
||||
}
|
||||
|
||||
|
30
js/main.js
30
js/main.js
@ -51,6 +51,10 @@ require('./mainApiMgr.js');
|
||||
require('./memoryMonitor.js');
|
||||
|
||||
const windowMgr = require('./windowMgr.js');
|
||||
const SpellChecker = require('./spellChecker').SpellCheckHelper;
|
||||
const spellchecker = new SpellChecker();
|
||||
const { ContextMenuBuilder } = require('electron-spellchecker');
|
||||
const i18n = require('./translation/i18n');
|
||||
|
||||
getConfigField('url')
|
||||
.then(initializeCrashReporter)
|
||||
@ -247,6 +251,32 @@ app.on('open-url', function (event, url) {
|
||||
handleProtocolAction(url);
|
||||
});
|
||||
|
||||
app.on('web-contents-created', function (event, webContents) {
|
||||
onWebContent(webContents);
|
||||
});
|
||||
|
||||
function onWebContent(webContents) {
|
||||
spellchecker.initializeSpellChecker();
|
||||
spellchecker.updateContextMenuLocale(i18n.getMessageFor('ContextMenu'));
|
||||
const contextMenuBuilder = new ContextMenuBuilder(spellchecker.spellCheckHandler, webContents, false, spellchecker.processMenu.bind(spellchecker));
|
||||
let currentLocale = i18n.getLanguage();
|
||||
|
||||
const contextMenuListener = (event, info) => {
|
||||
if (currentLocale !== i18n.getLanguage()) {
|
||||
contextMenuBuilder.setAlternateStringFormatter(spellchecker.getStringTable(i18n.getMessageFor('ContextMenu')));
|
||||
spellchecker.updateContextMenuLocale(i18n.getMessageFor('ContextMenu'));
|
||||
currentLocale = i18n.getLanguage();
|
||||
}
|
||||
contextMenuBuilder.showPopupMenu(info);
|
||||
};
|
||||
|
||||
webContents.on('context-menu', contextMenuListener);
|
||||
|
||||
webContents.once('destroyed', () => {
|
||||
webContents.removeListener('context-menu', contextMenuListener);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the config fields that are required for the menu items
|
||||
* then opens the main window
|
||||
|
@ -31,7 +31,6 @@ const KeyCodes = {
|
||||
let Search;
|
||||
let SearchUtils;
|
||||
let CryptoLib;
|
||||
let spellChecker;
|
||||
let isAltKey = false;
|
||||
let isMenuOpen = false;
|
||||
|
||||
@ -60,24 +59,6 @@ try {
|
||||
require('../downloadManager');
|
||||
let snackBar;
|
||||
|
||||
/**
|
||||
* Loads up the spell checker module
|
||||
*/
|
||||
function loadSpellChecker() {
|
||||
try {
|
||||
/* eslint-disable global-require */
|
||||
const SpellCheckerHelper = require('../spellChecker').SpellCheckHelper;
|
||||
/* eslint-enable global-require */
|
||||
// Method to initialize spell checker
|
||||
spellChecker = new SpellCheckerHelper();
|
||||
spellChecker.initializeSpellChecker();
|
||||
} catch (err) {
|
||||
/* eslint-disable no-console */
|
||||
console.error('unable to load the spell checker module, hence, skipping the spell check feature ' + err);
|
||||
/* eslint-enable no-console */
|
||||
}
|
||||
}
|
||||
|
||||
// hold ref so doesn't get GC'ed
|
||||
const local = {
|
||||
ipcRenderer: ipcRenderer
|
||||
@ -102,7 +83,6 @@ const throttledSetIsInMeetingStatus = throttle(1000, function (isInMeeting) {
|
||||
* an event triggered by the main process onload event
|
||||
*/
|
||||
local.ipcRenderer.on('on-page-load', () => {
|
||||
loadSpellChecker();
|
||||
snackBar = new SnackBar();
|
||||
|
||||
// only registers main window's preload
|
||||
@ -499,10 +479,6 @@ function createAPI() {
|
||||
if (dataObj.titleBar) {
|
||||
titleBar.updateLocale(dataObj.titleBar);
|
||||
}
|
||||
|
||||
if (dataObj.contextMenu && spellChecker) {
|
||||
spellChecker.updateContextMenuLocale(dataObj.contextMenu);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
const { remote } = require('electron');
|
||||
const { MenuItem } = remote;
|
||||
const { app, MenuItem } = require('electron');
|
||||
const { isMac } = require('./../utils/misc');
|
||||
const { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } = require('electron-spellchecker');
|
||||
const { SpellCheckHandler } = require('electron-spellchecker');
|
||||
const stringFormat = require('./../utils/stringFormat');
|
||||
|
||||
class SpellCheckHelper {
|
||||
@ -18,7 +17,6 @@ class SpellCheckHelper {
|
||||
*/
|
||||
initializeSpellChecker() {
|
||||
this.spellCheckHandler.automaticallyIdentifyLanguages = false;
|
||||
this.spellCheckHandler.attachToInput();
|
||||
|
||||
// This is only for window as in mac the
|
||||
// language is switched w.r.t to the current system language.
|
||||
@ -26,14 +24,9 @@ class SpellCheckHelper {
|
||||
// In windows we need to implement RxJS observable
|
||||
// in order to switch language dynamically
|
||||
if (!isMac) {
|
||||
const sysLocale = remote.app.getLocale() || 'en-US';
|
||||
const sysLocale = app.getLocale() || 'en-US';
|
||||
this.spellCheckHandler.switchLanguage(sysLocale);
|
||||
}
|
||||
|
||||
this.contextMenuBuilder = new ContextMenuBuilder(this.spellCheckHandler, null, false, this.processMenu.bind(this));
|
||||
this.contextMenuListener = new ContextMenuListener((info) => {
|
||||
this.contextMenuBuilder.showPopupMenu(info);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +35,6 @@ class SpellCheckHelper {
|
||||
*/
|
||||
updateContextMenuLocale(content) {
|
||||
this.localeContent = content;
|
||||
this.contextMenuBuilder.setAlternateStringFormatter(SpellCheckHelper.getStringTable(content));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,7 +43,8 @@ class SpellCheckHelper {
|
||||
* @param content {Object} - locale content for context menu
|
||||
* @return {Object} - String table for context menu
|
||||
*/
|
||||
static getStringTable(content) {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
getStringTable(content) {
|
||||
return {
|
||||
copyMail: () => content['Copy Email Address'] || `Copy Email Address`,
|
||||
copyLinkUrl: () => content['Copy Link'] || 'Copy Link',
|
||||
|
@ -21,7 +21,7 @@ const notify = require('./notify/electron-notify.js');
|
||||
const eventEmitter = require('./eventEmitter');
|
||||
const throttle = require('./utils/throttle.js');
|
||||
const { getConfigField, updateConfigField, readConfigFileSync, getMultipleConfigField } = require('./config.js');
|
||||
const { isMac, isNodeEnv, isWindowsOS, isDevEnv } = require('./utils/misc');
|
||||
const { isMac, isWindowsOS, isDevEnv } = require('./utils/misc');
|
||||
const { isWhitelisted, parseDomain } = require('./utils/whitelistHandler');
|
||||
const { initCrashReporterMain, initCrashReporterRenderer } = require('./crashReporter.js');
|
||||
const i18n = require('./translation/i18n');
|
||||
@ -41,7 +41,6 @@ let boundsChangeWindow;
|
||||
let alwaysOnTop = false;
|
||||
let position = 'lower-right';
|
||||
let display;
|
||||
let sandboxed = false;
|
||||
let isAutoReload = false;
|
||||
let devToolsEnabled = true;
|
||||
let isCustomTitleBarEnabled = true;
|
||||
@ -163,10 +162,9 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
||||
frame: !isCustomTitleBarEnabled,
|
||||
alwaysOnTop: false,
|
||||
webPreferences: {
|
||||
sandbox: sandboxed,
|
||||
nodeIntegration: isNodeEnv,
|
||||
sandbox: true,
|
||||
nodeIntegration: false,
|
||||
preload: preloadMainScript,
|
||||
nativeWindowOpen: true
|
||||
}
|
||||
};
|
||||
|
||||
|
12
package.json
12
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Symphony",
|
||||
"productName": "Symphony",
|
||||
"version": "3.3.2",
|
||||
"version": "3.4.0",
|
||||
"buildNumber": "0",
|
||||
"description": "Symphony desktop app (Foundation ODP)",
|
||||
"author": "Symphony",
|
||||
@ -75,11 +75,17 @@
|
||||
"url": "https://support.symphony.com"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.18.0",
|
||||
"babel-eslint": "^7.1.1",
|
||||
"babel-plugin-transform-async-to-generator": "^6.16.0",
|
||||
"babel-plugin-transform-runtime": "^6.15.0",
|
||||
"babel-preset-es2016-node5": "^1.1.2",
|
||||
"babel-register": "^6.18.0",
|
||||
"bluebird": "3.5.2",
|
||||
"browserify": "16.2.3",
|
||||
"chromedriver": "2.42.0",
|
||||
"cross-env": "5.2.0",
|
||||
"electron": "3.0.2",
|
||||
"electron": "3.0.5",
|
||||
"electron-builder": "20.28.4",
|
||||
"electron-builder-squirrel-windows": "12.3.0",
|
||||
"electron-chromedriver": "3.0.0-beta.1",
|
||||
@ -107,7 +113,7 @@
|
||||
"auto-launch": "5.0.5",
|
||||
"electron-dl": "1.12.0",
|
||||
"electron-log": "2.2.17",
|
||||
"electron-spellchecker": "1.1.2",
|
||||
"electron-spellchecker": "git+https://github.com/KiranNiranjan/electron-spellchecker.git#v3.0.5",
|
||||
"ffi": "git+https://github.com/keerthi16/node-ffi.git#v1.2.8",
|
||||
"filesize": "3.6.1",
|
||||
"keymirror": "0.1.1",
|
||||
|
Loading…
Reference in New Issue
Block a user