Skip to content

Commit

Permalink
Use optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Jul 24, 2020
1 parent 377dad4 commit a6c821b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/headless/converse-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,14 @@ converse.plugins.add('converse-status', {
}
_converse.idle_seconds = 0;
_converse.auto_changed_status = false; // Was the user's status changed by Converse?

const { unloadevent } = _converse;
window.addEventListener('click', _converse.onUserActivity);
window.addEventListener('focus', _converse.onUserActivity);
window.addEventListener('keypress', _converse.onUserActivity);
window.addEventListener('mousemove', _converse.onUserActivity);
const options = {'once': true, 'passive': true};
window.addEventListener(_converse.unloadevent, _converse.onUserActivity, options);
window.addEventListener(_converse.unloadevent, () => {
if (_converse.session) {
_converse.session.save('active', false);
}
});
window.addEventListener(unloadevent, _converse.onUserActivity, {'once': true, 'passive': true});
window.addEventListener(unloadevent, () => _converse.session?.save('active', false));
_converse.everySecondTrigger = window.setInterval(_converse.onEverySecond, 1000);
};

Expand Down

0 comments on commit a6c821b

Please sign in to comment.