Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Retry refreshing event data
Browse files Browse the repository at this point in the history
  • Loading branch information
flenny committed Apr 25, 2023
1 parent af4e31f commit 3585c2e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
}
})

// Refresh the events every 20 seconds, retry if the request fails
const refreshEvents = () => {
google.script.run.withSuccessHandler(events => {
eventData = Object.values(events)
updateEvents(eventData)
setTimeout(refreshEvents, POLL_INTERVAL)
}).getEvents()
google.script.run
.withFailureHandler(error => {
console.error(error)
setTimeout(refreshEvents, POLL_INTERVAL)
})
.withSuccessHandler(events => {
eventData = Object.values(events)
updateEvents(eventData)
setTimeout(refreshEvents, POLL_INTERVAL)
}).getEvents()
}

const populateData = async () => {
Expand Down

0 comments on commit 3585c2e

Please sign in to comment.