From a6c821be95d0bd0f9a856e2015fb03a1795eb94a Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 24 Jul 2020 03:50:41 +0200 Subject: [PATCH] Use optional chaining --- src/headless/converse-status.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/headless/converse-status.js b/src/headless/converse-status.js index 376a0d424..582d25741 100644 --- a/src/headless/converse-status.js +++ b/src/headless/converse-status.js @@ -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); };