1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +12:00

Pass isMigrationDone

This commit is contained in:
Adria Navarro 2024-01-08 13:42:38 +01:00
parent 3dcb3dec3f
commit 03a933005d
2 changed files with 12 additions and 6 deletions

View file

@ -2,6 +2,13 @@
import { Updating } from "@budibase/frontend-core" import { Updating } from "@budibase/frontend-core"
import { redirect, params } from "@roxi/routify" import { redirect, params } from "@roxi/routify"
import { API } from "api"
async function isMigrationDone() {
const response = await API.getMigrationStatus()
return response.migrated
}
async function onMigrationDone() { async function onMigrationDone() {
// For some reason routify params is not stripping the ? properly, so we need to check both with and without ? // For some reason routify params is not stripping the ? properly, so we need to check both with and without ?
const returnUrl = $params.returnUrl || $params["?returnUrl"] const returnUrl = $params.returnUrl || $params["?returnUrl"]
@ -9,4 +16,4 @@
} }
</script> </script>
<Updating {onMigrationDone} /> <Updating {isMigrationDone} {onMigrationDone} />

View file

@ -1,18 +1,17 @@
<script> <script>
import * as API from "../api" export let isMigrationDone
export let onMigrationDone export let onMigrationDone
export let timeoutSeconds = 3 * 60 // 3 minutes export let timeoutSeconds = 10 // 3 minutes
const loadTime = Date.now() const loadTime = Date.now()
let timedOut = false let timedOut = false
async function checkMigrationsFinished() { async function checkMigrationsFinished() {
setTimeout(async () => { setTimeout(async () => {
const response = await API.getMigrationStatus() const isMigrated = await isMigrationDone()
const timeoutMs = timeoutSeconds * 1000 const timeoutMs = timeoutSeconds * 1000
if (!response.migrated) { if (!isMigrated) {
if (loadTime + timeoutMs > Date.now()) { if (loadTime + timeoutMs > Date.now()) {
return checkMigrationsFinished() return checkMigrationsFinished()
} }