This commit is contained in:
wxiaoguang 2024-04-30 10:48:15 +08:00
parent 61b495e5ab
commit 24f06bfc32
3 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import $ from 'jquery';
import {GET} from '../modules/fetch.js';
import {toggleElem} from '../utils/dom.js';
import {logoutFromWorker} from '../modules/worker.js';
const {appSubUrl, notificationSettings, assetVersionEncoded} = window.config;
let notificationSequenceNumber = 0;
@ -95,7 +96,7 @@ export function initNotificationCount() {
type: 'close',
});
worker.port.close();
window.location.href = `${appSubUrl}/`;
logoutFromWorker();
} else if (event.data.type === 'close') {
worker.port.postMessage({
type: 'close',

View File

@ -2,6 +2,7 @@ import prettyMilliseconds from 'pretty-ms';
import {createTippy} from '../modules/tippy.js';
import {GET} from '../modules/fetch.js';
import {hideElem, showElem} from '../utils/dom.js';
import {logoutFromWorker} from '../modules/worker.js';
const {appSubUrl, notificationSettings, enableTimeTracking, assetVersionEncoded} = window.config;
@ -75,7 +76,7 @@ export function initStopwatch() {
type: 'close',
});
worker.port.close();
window.location.href = `${appSubUrl}/`;
logoutFromWorker();
} else if (event.data.type === 'close') {
worker.port.postMessage({
type: 'close',

View File

@ -0,0 +1,8 @@
const {appSubUrl} = window.config;
export function logoutFromWorker() {
// wait for a while because other requests (eg: logout) may be in the flight
setTimeout(() => {
window.location.href = `${appSubUrl}/`;
}, 5000);
}