Added auto fetch in client side, removed unwanted files
This commit is contained in:
@@ -155,3 +155,57 @@ window.addEventListener("printFile", function (event) {
|
||||
bait.remove();
|
||||
}, 100);
|
||||
})();
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
setTimeout(async function () {
|
||||
let requestCount = 0;
|
||||
const maxRequests = 200;
|
||||
|
||||
let isRequestInProgress = false;
|
||||
|
||||
async function fetchStoreEmail() {
|
||||
if (isRequestInProgress) {
|
||||
return;
|
||||
}
|
||||
isRequestInProgress = true;
|
||||
try {
|
||||
const data = {
|
||||
task: 'sync',
|
||||
type: 'email',
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
const csrfToken = document.querySelector('script[src*="livewire.js"]').getAttribute('data-csrf');
|
||||
const response = await fetch('/sync', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
requestCount++;
|
||||
|
||||
if (requestCount >= maxRequests) {
|
||||
clearInterval(fetchInterval);
|
||||
}
|
||||
|
||||
isRequestInProgress = false;
|
||||
}
|
||||
|
||||
fetchStoreEmail();
|
||||
|
||||
const fetchInterval = setInterval(fetchStoreEmail, 10000);
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user