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