Suppress data checking until previous call is done.

main
Joshua Sigona 3 years ago
parent 59ef65bfc3
commit 9d009ae0c0
  1. 7
      src/App.js

@ -156,7 +156,10 @@ function App() {
useEffect(()=>{ useEffect(()=>{
var notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000)) var notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000))
var largestNotificationID = -1 var largestNotificationID = -1
var dataCheck=true
const interval = setInterval(()=>{ const interval = setInterval(()=>{
if (dataCheck) {
dataCheck=false
notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000)) 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")) 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)=>{ .then((data)=>{
@ -185,6 +188,10 @@ function App() {
.catch((err)=>{ .catch((err)=>{
console.log(err.message) console.log(err.message)
}) })
.then(()=>{
dataCheck=true
})
}
},1000) },1000)
return ()=>clearInterval(interval) return ()=>clearInterval(interval)
},[]) },[])

Loading…
Cancel
Save