Adding a minimum time to the app migration screen and adding a link to documentation.
This commit is contained in:
parent
1e34411d66
commit
8970705b39
|
@ -1,18 +1,22 @@
|
||||||
<script>
|
<script>
|
||||||
export let isMigrationDone
|
export let isMigrationDone
|
||||||
export let onMigrationDone
|
export let onMigrationDone
|
||||||
export let timeoutSeconds = 10 // 3 minutes
|
export let timeoutSeconds = 60 // 1 minute
|
||||||
|
export let minTimeSeconds = 3
|
||||||
|
|
||||||
const loadTime = Date.now()
|
const loadTime = Date.now()
|
||||||
|
const intervalMs = 1000
|
||||||
let timedOut = false
|
let timedOut = false
|
||||||
|
let secondsWaited = 0
|
||||||
|
|
||||||
async function checkMigrationsFinished() {
|
async function checkMigrationsFinished() {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const isMigrated = await isMigrationDone()
|
const isMigrated = await isMigrationDone()
|
||||||
|
|
||||||
const timeoutMs = timeoutSeconds * 1000
|
const timeoutMs = timeoutSeconds * 1000
|
||||||
if (!isMigrated) {
|
if (!isMigrated || secondsWaited <= minTimeSeconds) {
|
||||||
if (loadTime + timeoutMs > Date.now()) {
|
if (loadTime + timeoutMs > Date.now()) {
|
||||||
|
secondsWaited += 1
|
||||||
return checkMigrationsFinished()
|
return checkMigrationsFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onMigrationDone()
|
onMigrationDone()
|
||||||
}, 1000)
|
}, intervalMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMigrationsFinished()
|
checkMigrationsFinished()
|
||||||
|
@ -41,6 +45,11 @@
|
||||||
<span class="subtext">
|
<span class="subtext">
|
||||||
{#if !timedOut}
|
{#if !timedOut}
|
||||||
Please wait and we will be back in a second!
|
Please wait and we will be back in a second!
|
||||||
|
<br />
|
||||||
|
Checkout the
|
||||||
|
<a href="https://docs.budibase.com/docs/app-migrations" target="_blank"
|
||||||
|
>documentation</a
|
||||||
|
> on app migrations.
|
||||||
{:else}
|
{:else}
|
||||||
An error occurred, please try again later.
|
An error occurred, please try again later.
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -23,16 +23,15 @@ const getCacheKey = (appId: string) => `appmigrations_${env.VERSION}_${appId}`
|
||||||
export async function getAppMigrationVersion(appId: string): Promise<string> {
|
export async function getAppMigrationVersion(appId: string): Promise<string> {
|
||||||
const cacheKey = getCacheKey(appId)
|
const cacheKey = getCacheKey(appId)
|
||||||
|
|
||||||
let metadata: AppMigrationDoc | undefined = await cache.get(cacheKey)
|
let version: string | undefined = await cache.get(cacheKey)
|
||||||
|
|
||||||
// returned cached version if we found one
|
// returned cached version if we found one
|
||||||
if (metadata?.version) {
|
if (version) {
|
||||||
return metadata.version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
let version
|
|
||||||
try {
|
try {
|
||||||
metadata = await getFromDB(appId)
|
const metadata = await getFromDB(appId)
|
||||||
version = metadata.version || ""
|
version = metadata.version || ""
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.status !== 404) {
|
if (err.status !== 404) {
|
||||||
|
|
Loading…
Reference in New Issue