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:
committed by
Vishwas Shashidhar
parent
1089fe62c1
commit
7fea8b0383
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
|
||||
|
||||
Reference in New Issue
Block a user