Pass isMigrationDone
This commit is contained in:
parent
3dcb3dec3f
commit
03a933005d
|
@ -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} />
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue