Skip to content

Commit

Permalink
perf: Improve away detection (#1542)
Browse files Browse the repository at this point in the history
* feat: Added option to disable GPU acceleration

* [IMPROVE] improve away detection
  • Loading branch information
Somtozech authored Mar 10, 2020
1 parent 18c850c commit 6449554
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/preload/userPresence.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { remote } from 'electron';
import { remote, app } from 'electron';

import { getMeteor, getTracker, getGetUserPreference, getUserPresence } from './rocketChat';

Expand Down Expand Up @@ -41,6 +41,18 @@ const handleUserPresence = () => {
}, 1000);
};

// if the system is put to sleep or screen is locked(windows OS), set userPresence to away
const handleSystemActions = () => {
const Meteor = getMeteor();
remote.powerMonitor.on('suspend', () => {
Meteor.call('UserPresence:away');
});
// windows OS only
remote.powerMonitor.on('lock-screen', () => {
Meteor.call('UserPresence:away');
});
};
export default () => {
window.addEventListener('load', handleUserPresence);
window.addEventListener('load', handleSystemActions);
};

0 comments on commit 6449554

Please sign in to comment.