|
|
|
@ -25,9 +25,11 @@ import AppLogo from '@/assets/highlights_travel_300_300.png'
|
|
|
|
|
import '@/assets/App.css'
|
|
|
|
|
import 'react-chat-elements/dist/main.css'
|
|
|
|
|
import EmailFetch from './Conversations/Online/Components/EmailFetch'
|
|
|
|
|
import { getEmailFetchAction } from '@/actions/EmailActions'
|
|
|
|
|
import FetchEmailWorker from './../workers/fetchEmailWorker?worker&url'
|
|
|
|
|
|
|
|
|
|
// const fetchEmailWorkerURL = new URL('/src/workers/fetchEmailWorker.js', import.meta.url);
|
|
|
|
|
const fetchEmailWorker = new Worker(FetchEmailWorker, { type: 'module' });
|
|
|
|
|
|
|
|
|
|
const fetchEmailWorkerURL = new URL('./../workers/fetchEmailWorker.js', import.meta.url);
|
|
|
|
|
|
|
|
|
|
function AuthApp() {
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
@ -54,28 +56,34 @@ function AuthApp() {
|
|
|
|
|
} else {
|
|
|
|
|
Notification.requestPermission()
|
|
|
|
|
}
|
|
|
|
|
let fetchEmailWorker;
|
|
|
|
|
let _fetchEmailWorker;
|
|
|
|
|
if (loginUser.userId > 0) {
|
|
|
|
|
appendRequestHeader('X-User-Id', loginUser.userId)
|
|
|
|
|
loadPageSpy(loginUser.username)
|
|
|
|
|
connectWebsocket(loginUser.userId)
|
|
|
|
|
fetchInitialData(loginUser)
|
|
|
|
|
|
|
|
|
|
let fetchEmailWorker;
|
|
|
|
|
let _fetchEmailWorker;
|
|
|
|
|
if (isPermitted(PERM_USE_EMAL)) {
|
|
|
|
|
fetchEmailWorker = startEmailInterval(loginUser.userId)
|
|
|
|
|
_fetchEmailWorker = startEmailInterval(loginUser.userId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
disconnectWebsocket()
|
|
|
|
|
if (fetchEmailWorker) {
|
|
|
|
|
fetchEmailWorker.terminate();
|
|
|
|
|
if (_fetchEmailWorker) {
|
|
|
|
|
_fetchEmailWorker.terminate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
const startEmailInterval = (userId) => {
|
|
|
|
|
const fetchEmailWorker = new Worker(fetchEmailWorkerURL, { type: 'module' });
|
|
|
|
|
// 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;
|
|
|
|
|
// setInterval(() => {
|
|
|
|
|