mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-483 (Implement a functionality to display snack bar) (#390)
- Implement a functionality to display snack bar - Localize snack bar - Move key press logic to windowMgr - Center snackbar - Add functionality to remove snackbar on leave-full-screen event - Add safety check - optimize code to listen keydown event only if the window is in full screen
This commit is contained in:
committed by
Vishwas Shashidhar
parent
131076c2b0
commit
cc39f43ee7
@@ -23,16 +23,13 @@ const { TitleBar, updateContentHeight } = require('../windowsTitlebar');
|
||||
const titleBar = new TitleBar();
|
||||
const { buildNumber } = require('../../package.json');
|
||||
const memoryMonitorInterval = 1000 * 60 * 60;
|
||||
const SnackBar = require('../snackBar').SnackBar;
|
||||
const KeyCodes = {
|
||||
Esc: 27,
|
||||
};
|
||||
|
||||
require('../downloadManager');
|
||||
|
||||
// bug in electron preventing us from using spellchecker in pop outs
|
||||
// https://github.com/electron/electron/issues/4025
|
||||
// so loading the spellchecker in try catch so that we don't
|
||||
// block other method from loading
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
loadSpellChecker();
|
||||
});
|
||||
let snackBar;
|
||||
|
||||
/**
|
||||
* Loads up the spell checker module
|
||||
@@ -72,6 +69,14 @@ 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();
|
||||
});
|
||||
|
||||
// Gathers renderer process memory
|
||||
setInterval(() => {
|
||||
const memory = process.getProcessMemoryInfo();
|
||||
@@ -430,6 +435,28 @@ function createAPI() {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* an event triggered by the main process when
|
||||
* the window enters full screen
|
||||
*/
|
||||
local.ipcRenderer.on('window-enter-full-screen', (event, arg) => {
|
||||
window.addEventListener('keydown', throttledKeyDown, true);
|
||||
if (snackBar && typeof arg === 'object' && arg.snackBar) {
|
||||
setTimeout(() => snackBar.showSnackBar(arg.snackBar), 500);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* an event triggered by the main process when
|
||||
* the window leave full screen
|
||||
*/
|
||||
local.ipcRenderer.on('window-leave-full-screen', () => {
|
||||
window.removeEventListener('keydown', throttledKeyDown, true);
|
||||
if (snackBar) {
|
||||
snackBar.removeSnackBar();
|
||||
}
|
||||
});
|
||||
|
||||
function updateOnlineStatus() {
|
||||
local.ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.isOnline,
|
||||
@@ -445,6 +472,15 @@ function createAPI() {
|
||||
});
|
||||
}
|
||||
|
||||
const throttledKeyDown = throttle(1000, (event) => {
|
||||
if (event.keyCode === KeyCodes.Esc) {
|
||||
local.ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.keyPress,
|
||||
keyCode: KeyCodes.Esc
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('offline', updateOnlineStatus, false);
|
||||
window.addEventListener('online', updateOnlineStatus, false);
|
||||
window.addEventListener('beforeunload', sanitize, false);
|
||||
|
||||
Reference in New Issue
Block a user