mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-445 - Change API from presence status to meeting status
This commit is contained in:
committed by
kiranniranjan
parent
296af7fad5
commit
2fe67c6fb6
@@ -21,7 +21,7 @@ const cmds = keyMirror({
|
||||
openScreenPickerWindow: null,
|
||||
popupMenu: null,
|
||||
optimizeMemoryConsumption: null,
|
||||
setPresenceStatus: null
|
||||
setIsInMeeting: null
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -17,7 +17,7 @@ const { bringToFront } = require('./bringToFront.js');
|
||||
const eventEmitter = require('./eventEmitter');
|
||||
const { isMac } = require('./utils/misc');
|
||||
const { openScreenPickerWindow } = require('./desktopCapturer');
|
||||
const { optimizeMemory, setPresenceStatus } = require('./memoryMonitor');
|
||||
const { optimizeMemory, setIsInMeeting } = require('./memoryMonitor');
|
||||
|
||||
const apiEnums = require('./enums/api.js');
|
||||
const apiCmds = apiEnums.cmds;
|
||||
@@ -153,9 +153,9 @@ electron.ipcMain.on(apiName, (event, arg) => {
|
||||
optimizeMemory(arg.memory);
|
||||
}
|
||||
break;
|
||||
case apiCmds.setPresenceStatus:
|
||||
if (typeof arg.status === 'string') {
|
||||
setPresenceStatus(arg.status);
|
||||
case apiCmds.setIsInMeeting:
|
||||
if (typeof arg.isInMeeting === 'boolean') {
|
||||
setIsInMeeting(arg.isInMeeting);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -6,13 +6,12 @@ const { getMainWindow, setIsAutoReload } = require('./windowMgr');
|
||||
const systemIdleTime = require('@paulcbetts/system-idle-time');
|
||||
const { getConfigField } = require('./config');
|
||||
|
||||
const awayStatus = 'AWAY';
|
||||
const maxMemory = 800;
|
||||
|
||||
let maxIdleTime = 4 * 60 * 1000;
|
||||
let reloadThreshold = 30 * 60 * 1000;
|
||||
let reloadedTimeStamp;
|
||||
let userPresenceStatus;
|
||||
let isInMeeting = false;
|
||||
|
||||
// once a minute
|
||||
setInterval(gatherMemory, 1000 * 60);
|
||||
@@ -41,7 +40,7 @@ function optimizeMemory(memoryInfo) {
|
||||
const memoryConsumed = (memoryInfo && memoryInfo.workingSetSize / 1024) || 0;
|
||||
const canReload = (!reloadedTimeStamp || (new Date().getTime() - reloadedTimeStamp) > reloadThreshold);
|
||||
|
||||
if (memoryConsumed > maxMemory && systemIdleTime.getIdleTime() > maxIdleTime && canReload && !isUserActive()) {
|
||||
if (memoryConsumed > maxMemory && systemIdleTime.getIdleTime() > maxIdleTime && canReload && !isInMeeting) {
|
||||
getConfigField('memoryRefresh')
|
||||
.then((enabled) => {
|
||||
if (enabled) {
|
||||
@@ -53,7 +52,7 @@ function optimizeMemory(memoryInfo) {
|
||||
log.send(logLevels.INFO, 'Reloading the app to optimize memory usage as' +
|
||||
' memory consumption was ' + memoryConsumed +
|
||||
' user activity tick was ' + systemIdleTime.getIdleTime() +
|
||||
' user presence status was ' + userPresenceStatus );
|
||||
' user was in a meeting? ' + isInMeeting );
|
||||
mainWindow.reload();
|
||||
}
|
||||
}
|
||||
@@ -62,23 +61,14 @@ function optimizeMemory(memoryInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the user presence status to see
|
||||
* if the user is active
|
||||
* @return {boolean}
|
||||
* Sets the current user meeting status
|
||||
* @param bool - Whether user is in an active meeting
|
||||
*/
|
||||
function isUserActive() {
|
||||
return !(userPresenceStatus && userPresenceStatus === awayStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user presence status
|
||||
* @param status
|
||||
*/
|
||||
function setPresenceStatus(status) {
|
||||
userPresenceStatus = status;
|
||||
function setIsInMeeting(bool) {
|
||||
isInMeeting = bool;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
optimizeMemory,
|
||||
setPresenceStatus
|
||||
setIsInMeeting
|
||||
};
|
||||
@@ -64,10 +64,10 @@ const throttledSetBadgeCount = throttle(1000, function(count) {
|
||||
});
|
||||
});
|
||||
|
||||
const throttledSetPresenceStatus = throttle(1000, function(status) {
|
||||
const throttledSetIsInMeetingStatus = throttle(1000, function(isInMeeting) {
|
||||
local.ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.setPresenceStatus,
|
||||
status: status
|
||||
cmd: apiCmds.setIsInMeeting,
|
||||
isInMeeting
|
||||
});
|
||||
});
|
||||
|
||||
@@ -296,11 +296,11 @@ function createAPI() {
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets user presence status
|
||||
* Sets if the user is in an active meeting
|
||||
* will be used to handle memory refresh functionality
|
||||
*/
|
||||
setPresenceStatus: function (status) {
|
||||
throttledSetPresenceStatus(status);
|
||||
setIsInMeeting: function (isInMeeting) {
|
||||
throttledSetIsInMeetingStatus(isInMeeting);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user