Move code that sets active
flag on session to initSession
It doesn't belong in the `converse-status` plugin and the event handler doesn't get registered when all CSI-related timeouts are set to 0.
This commit is contained in:
parent
0df1c1880e
commit
71d1383604
@ -101,10 +101,11 @@ export function sendCSI (stat) {
|
|||||||
_converse.inactive = (stat === _converse.INACTIVE) ? true : false;
|
_converse.inactive = (stat === _converse.INACTIVE) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerIntervalHandler () {
|
/**
|
||||||
/* Set an interval of one second and register a handler for it.
|
* Set an interval of one second and register a handler for it.
|
||||||
* Required for the auto_away, auto_xa and csi_waiting_time features.
|
* Required for the auto_away, auto_xa and csi_waiting_time features.
|
||||||
*/
|
*/
|
||||||
|
export function registerIntervalHandler () {
|
||||||
if (
|
if (
|
||||||
api.settings.get("auto_away") < 1 &&
|
api.settings.get("auto_away") < 1 &&
|
||||||
api.settings.get("auto_xa") < 1 &&
|
api.settings.get("auto_xa") < 1 &&
|
||||||
@ -123,7 +124,6 @@ export function registerIntervalHandler () {
|
|||||||
window.addEventListener('keypress', _converse.onUserActivity);
|
window.addEventListener('keypress', _converse.onUserActivity);
|
||||||
window.addEventListener('mousemove', _converse.onUserActivity);
|
window.addEventListener('mousemove', _converse.onUserActivity);
|
||||||
window.addEventListener(unloadevent, _converse.onUserActivity, {'once': true, 'passive': true});
|
window.addEventListener(unloadevent, _converse.onUserActivity, {'once': true, 'passive': true});
|
||||||
window.addEventListener(unloadevent, () => _converse.session?.save('active', false));
|
|
||||||
_converse.everySecondTrigger = window.setInterval(_converse.onEverySecond, 1000);
|
_converse.everySecondTrigger = window.setInterval(_converse.onEverySecond, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,7 @@ function saveJIDtoSession (_converse, jid) {
|
|||||||
// We use the `active` flag to determine whether we should use the values from sessionStorage.
|
// We use the `active` flag to determine whether we should use the values from sessionStorage.
|
||||||
// When "cloning" a tab (e.g. via middle-click), the `active` flag will be set and we'll create
|
// When "cloning" a tab (e.g. via middle-click), the `active` flag will be set and we'll create
|
||||||
// a new empty user session, otherwise it'll be false and we can re-use the user session.
|
// a new empty user session, otherwise it'll be false and we can re-use the user session.
|
||||||
|
// When the tab is reloaded, the `active` flag is set to `false`.
|
||||||
'active': true
|
'active': true
|
||||||
});
|
});
|
||||||
// Set JID on the connection object so that when we call `connection.bind`
|
// Set JID on the connection object so that when we call `connection.bind`
|
||||||
@ -184,6 +185,10 @@ export async function initSession (_converse, jid) {
|
|||||||
_converse.session.save({id});
|
_converse.session.save({id});
|
||||||
}
|
}
|
||||||
saveJIDtoSession(_converse, jid);
|
saveJIDtoSession(_converse, jid);
|
||||||
|
|
||||||
|
// Set `active` flag to false when the tab gets reloaded
|
||||||
|
window.addEventListener(_converse.unloadevent, () => _converse.session?.save('active', false));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered once the user's session has been initialized. The session is a
|
* Triggered once the user's session has been initialized. The session is a
|
||||||
* cache which stores information about the user's current session.
|
* cache which stores information about the user's current session.
|
||||||
|
Loading…
Reference in New Issue
Block a user