Change interval for timeout

This commit is contained in:
Adria Navarro 2023-12-14 12:52:51 +01:00
parent 342a1b487b
commit 3a2a2a242c
1 changed files with 17 additions and 9 deletions

View File

@ -2,19 +2,27 @@
import Spinner from "components/common/Spinner.svelte"
import { API } from "api"
setInterval(async () => {
const response = await API.get({ url: "/api/migrations/status" })
if (!response.migrated) {
return
}
let timeout
async function checkMigrationsFinished() {
timeout = setTimeout(async () => {
const response = await API.get({ url: "/api/migrations/status" })
if (!response.migrated) {
checkMigrationsFinished()
return
}
const urlParams = new URLSearchParams(window.location.search)
const returnUrl = urlParams.get("returnUrl")
const urlParams = new URLSearchParams(window.location.search)
const returnUrl = urlParams.get("returnUrl")
window.location = returnUrl
}, 1000)
window.location = returnUrl
}, 1000)
}
checkMigrationsFinished()
setTimeout(() => {
clearTimeout(timeout)
// TODO
alert("Something went wrong 💀")
}, 60000)
</script>