Skip to content

Commit 24f06bf

Browse files
committed
fix
1 parent 61b495e commit 24f06bf

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

web_src/js/features/notification.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import $ from 'jquery';
22
import {GET} from '../modules/fetch.js';
33
import {toggleElem} from '../utils/dom.js';
4+
import {logoutFromWorker} from '../modules/worker.js';
45

56
const {appSubUrl, notificationSettings, assetVersionEncoded} = window.config;
67
let notificationSequenceNumber = 0;
@@ -95,7 +96,7 @@ export function initNotificationCount() {
9596
type: 'close',
9697
});
9798
worker.port.close();
98-
window.location.href = `${appSubUrl}/`;
99+
logoutFromWorker();
99100
} else if (event.data.type === 'close') {
100101
worker.port.postMessage({
101102
type: 'close',

web_src/js/features/stopwatch.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import prettyMilliseconds from 'pretty-ms';
22
import {createTippy} from '../modules/tippy.js';
33
import {GET} from '../modules/fetch.js';
44
import {hideElem, showElem} from '../utils/dom.js';
5+
import {logoutFromWorker} from '../modules/worker.js';
56

67
const {appSubUrl, notificationSettings, enableTimeTracking, assetVersionEncoded} = window.config;
78

@@ -75,7 +76,7 @@ export function initStopwatch() {
7576
type: 'close',
7677
});
7778
worker.port.close();
78-
window.location.href = `${appSubUrl}/`;
79+
logoutFromWorker();
7980
} else if (event.data.type === 'close') {
8081
worker.port.postMessage({
8182
type: 'close',

web_src/js/modules/worker.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const {appSubUrl} = window.config;
2+
3+
export function logoutFromWorker() {
4+
// wait for a while because other requests (eg: logout) may be in the flight
5+
setTimeout(() => {
6+
window.location.href = `${appSubUrl}/`;
7+
}, 5000);
8+
}

0 commit comments

Comments
 (0)