let isLoggingOut = false;
let logoutConnectionCheckInterval = null;
async function logoutOnConnectionCheck() {
try {
const result = await Utils.fetch("{{ path('index') }}");
if (!isLoggingOut && result.xhr.status === 200) {
isLoggingOut = true;
clearInterval(logoutConnectionCheckInterval);
location.href = "{{ path('logout') }}";
}
} catch (error) {
}
}
function startLogoutOnConnectionCheck() {
if (logoutConnectionCheckInterval) {
return;
}
logoutOnConnectionCheck();
logoutConnectionCheckInterval = setInterval(() => {
logoutOnConnectionCheck();
}, 2000);
}
let isReloadAfter1Min = false;
function reloadAfter1Min() {
if (isReloadAfter1Min) {
return;
}
isReloadAfter1Min = true;
setTimeout(() => {
setInterval(async () => {
try {
const result = await Utils.fetch("{{ path('index') }}");
if (result.xhr.status === 200) {
location.reload();
}
} catch (e) {}
}, 2000);
}, 60000);
}
function startLogoutOnSessionExpire() {
setInterval(async () => {
try {
const result = await Utils.fetch("{{ path('moderator_app_settings_session_seconds_left') }}");
if (result.response && result.response.toString() && result.response.toString().match(/^\d+$/)) {
if (result.response <= 0) {
startLogoutOnConnectionCheck();
}
} else {
startLogoutOnConnectionCheck();
}
} catch (error) {
}
}, 5000);
}
{% if app.request.attributes.get('_route') == 'login' %}
reloadAfter1Min();
{% else %}
startLogoutOnSessionExpire();
{% endif %}