退出登录就不收件了

dev/emitter
Lei OT 10 months ago
parent 3100a3c768
commit f0ac38fe1b

@ -70,6 +70,7 @@ function AuthApp() {
}
return () => {
disconnectWebsocket()
fetchEmailWorker.postMessage({ command: 'logout' })
if (_fetchEmailWorker) {
_fetchEmailWorker.terminate();
}

@ -1,5 +1,6 @@
import { getEmailFetchAction } from './../actions/EmailActions'
let timeoutID;
self.onmessage = (event) => {
if (event.data.command === 'fetchEmail') {
// Get the parameter
@ -7,9 +8,24 @@ self.onmessage = (event) => {
console.log('Worker: Received command `fetchEmail` with param:', param)
// Do something......
setInterval(() => {
getEmailFetchAction(param)
}, 10 * 1000) // prod: 30 minutes
const fetchEmails = () => {
try {
getEmailFetchAction(param);
} catch (error) {}
timeoutID = setTimeout(fetchEmails, 10 * 1000); // prod: 30 minutes
};
// Start fetching emails
fetchEmails();
// intervalID = setInterval(() => {
// getEmailFetchAction(param)
// }, 10 * 1000) // prod: 30 minutes
// getEmailFetchAction(param)
}
if (event.data.command === 'logout') {
console.log('logout')
// clearInterval(intervalID)
clearTimeout(timeoutID)
}
}
self.onerror = function (error) {

Loading…
Cancel
Save