fix: update on mobile
This commit is contained in:
parent
75af551435
commit
fe7390bd4d
@ -1,7 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { dev } from '$app/env';
|
||||
import { get, post } from '$lib/api';
|
||||
import { addToast, appSession, features, updateLoading, isUpdateAvailable } from '$lib/store';
|
||||
import {
|
||||
addToast,
|
||||
appSession,
|
||||
features,
|
||||
updateLoading,
|
||||
isUpdateAvailable,
|
||||
latestVersion
|
||||
} from '$lib/store';
|
||||
import { asyncSleep, errorNotification } from '$lib/common';
|
||||
import { onMount } from 'svelte';
|
||||
import Tooltip from './Tooltip.svelte';
|
||||
@ -11,17 +18,17 @@
|
||||
loading: false,
|
||||
success: null
|
||||
};
|
||||
let latestVersion = 'latest';
|
||||
async function update() {
|
||||
updateStatus.loading = true;
|
||||
try {
|
||||
if (dev) {
|
||||
localStorage.setItem('lastVersion', $appSession.version);
|
||||
await asyncSleep(1000);
|
||||
updateStatus.loading = false;
|
||||
return window.location.reload();
|
||||
} else {
|
||||
localStorage.setItem('lastVersion', $appSession.version);
|
||||
await post(`/update`, { type: 'update', latestVersion });
|
||||
await post(`/update`, { type: 'update', latestVersion: $latestVersion });
|
||||
addToast({
|
||||
message: 'Update completed.<br><br>Waiting for the new version to start...',
|
||||
type: 'success'
|
||||
@ -64,7 +71,7 @@
|
||||
$updateLoading = true;
|
||||
const data = await get(`/update`);
|
||||
if (overrideVersion || data?.isUpdateAvailable) {
|
||||
latestVersion = overrideVersion || data.latestVersion;
|
||||
$latestVersion = overrideVersion || data.latestVersion;
|
||||
if (overrideVersion) {
|
||||
$isUpdateAvailable = true;
|
||||
} else {
|
||||
@ -93,7 +100,7 @@
|
||||
{#if updateStatus.loading}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="lds-heart h-8 w-8"
|
||||
class="lds-heart h-8 w-8 mx-auto"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
@ -110,7 +117,7 @@
|
||||
<div class="flex items-center justify-center space-x-2">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-8 w-8"
|
||||
class="h-8 w-8 mx-auto"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
|
@ -32,6 +32,7 @@ interface AddToast {
|
||||
}
|
||||
export const updateLoading: Writable<boolean> = writable(false);
|
||||
export const isUpdateAvailable: Writable<boolean> = writable(false);
|
||||
export const latestVersion: Writable<string> = writable('latest');
|
||||
export const search: any = writable('')
|
||||
export const loginEmail: Writable<string | undefined> = writable()
|
||||
export const appSession: Writable<AppSession> = writable({
|
||||
|
Loading…
x
Reference in New Issue
Block a user