Skip to content

Commit 6449554

Browse files
authored
perf: Improve away detection (#1542)
* feat: Added option to disable GPU acceleration * [IMPROVE] improve away detection
1 parent 18c850c commit 6449554

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/preload/userPresence.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { remote } from 'electron';
1+
import { remote, app } from 'electron';
22

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

@@ -41,6 +41,18 @@ const handleUserPresence = () => {
4141
}, 1000);
4242
};
4343

44+
// if the system is put to sleep or screen is locked(windows OS), set userPresence to away
45+
const handleSystemActions = () => {
46+
const Meteor = getMeteor();
47+
remote.powerMonitor.on('suspend', () => {
48+
Meteor.call('UserPresence:away');
49+
});
50+
// windows OS only
51+
remote.powerMonitor.on('lock-screen', () => {
52+
Meteor.call('UserPresence:away');
53+
});
54+
};
4455
export default () => {
4556
window.addEventListener('load', handleUserPresence);
57+
window.addEventListener('load', handleSystemActions);
4658
};

0 commit comments

Comments
 (0)