|
|
|
@ -56,38 +56,21 @@ function AuthApp() {
|
|
|
|
|
} else {
|
|
|
|
|
Notification.requestPermission()
|
|
|
|
|
}
|
|
|
|
|
let _fetchEmailWorker;
|
|
|
|
|
if (loginUser.userId > 0) {
|
|
|
|
|
appendRequestHeader('X-User-Id', loginUser.userId)
|
|
|
|
|
loadPageSpy(loginUser.username)
|
|
|
|
|
connectWebsocket(loginUser.userId)
|
|
|
|
|
fetchInitialData(loginUser)
|
|
|
|
|
|
|
|
|
|
_fetchEmailWorker = startEmailInterval(loginUser.userId)
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
disconnectWebsocket()
|
|
|
|
|
fetchEmailWorker.postMessage({ command: 'logout' })
|
|
|
|
|
if (_fetchEmailWorker) {
|
|
|
|
|
_fetchEmailWorker.terminate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useGlobalNotify();
|
|
|
|
|
|
|
|
|
|
const startEmailInterval = (userId) => {
|
|
|
|
|
// const fetchEmailWorker = new Worker(fetchEmailWorkerURL, { type: 'module' });
|
|
|
|
|
fetchEmailWorker.onerror = function(error) {
|
|
|
|
|
console.error('There was an error in the worker', error);
|
|
|
|
|
};
|
|
|
|
|
fetchEmailWorker.onmessage = function(event) {
|
|
|
|
|
// console.log('Received message from worker', event.data, event.message);
|
|
|
|
|
};
|
|
|
|
|
fetchEmailWorker.postMessage({ command: 'fetchEmail', param: { opi_sn: userId } });
|
|
|
|
|
return fetchEmailWorker;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uploadLog = async () => {
|
|
|
|
|
await readWebsocketLog()
|
|
|
|
|
if (window.$pageSpy) {
|
|
|
|
|