Suppress data checking until previous call is done.

This commit is contained in:
Joshua Sigona 2021-08-28 12:19:20 +09:00
parent 59ef65bfc3
commit 9d009ae0c0

View File

@ -156,7 +156,10 @@ function App() {
useEffect(()=>{
var notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000))
var largestNotificationID = -1
var dataCheck=true
const interval = setInterval(()=>{
if (dataCheck) {
dataCheck=false
notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000))
axios.get(BACKEND_URL+"/getNotifications?date="+encodeURIComponent(LZ(4,notificationLastUpdate.getUTCFullYear())+"-"+LZ(2,notificationLastUpdate.getUTCMonth()+1)+"-"+LZ(2,notificationLastUpdate.getUTCDate())+" "+LZ(2,notificationLastUpdate.getUTCHours())+":"+LZ(2,notificationLastUpdate.getUTCMinutes())+":"+LZ(2,notificationLastUpdate.getUTCSeconds())+"."+LZ(3,notificationLastUpdate.getUTCMilliseconds())+"+00"))
.then((data)=>{
@ -185,6 +188,10 @@ function App() {
.catch((err)=>{
console.log(err.message)
})
.then(()=>{
dataCheck=true
})
}
},1000)
return ()=>clearInterval(interval)
},[])