mirror of
https://github.com/immich-app/immich
synced 2026-08-29 13:15:45 +00:00
refactor: wait on WebSocket connection to refresh
This commit is contained in:
parent
2afbff36a3
commit
7b28284ddf
2 changed files with 22 additions and 22 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { getServerConfig, startMaintenance } from '@immich/sdk';
|
||||
import { websocketStore } from '$lib/stores/websocket';
|
||||
import { startMaintenance } from '@immich/sdk';
|
||||
import { Button } from '@immich/ui';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
|
|
@ -10,17 +11,16 @@
|
|||
let { disabled = false }: Props = $props();
|
||||
|
||||
async function enable() {
|
||||
await startMaintenance();
|
||||
let waiting = false;
|
||||
websocketStore.connected.subscribe((connected) => {
|
||||
if (!connected) {
|
||||
waiting = true;
|
||||
} else if (connected && waiting) {
|
||||
location.href = '/';
|
||||
}
|
||||
});
|
||||
|
||||
// poll the server until it comes back online
|
||||
setInterval(
|
||||
() =>
|
||||
void getServerConfig()
|
||||
// eslint-disable-next-line no-self-assign
|
||||
.then(() => (location.href = location.href))
|
||||
.catch(() => {}),
|
||||
1000,
|
||||
);
|
||||
await startMaintenance();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
<script>
|
||||
import AuthPageLayout from '$lib/components/layouts/AuthPageLayout.svelte';
|
||||
import { user } from '$lib/stores/user.store';
|
||||
import { endMaintenance, getServerConfig } from '@immich/sdk';
|
||||
import { websocketStore } from '$lib/stores/websocket';
|
||||
import { endMaintenance } from '@immich/sdk';
|
||||
import { Button, Heading } from '@immich/ui';
|
||||
|
||||
async function exit() {
|
||||
await endMaintenance();
|
||||
let waiting = false;
|
||||
websocketStore.connected.subscribe((connected) => {
|
||||
if (!connected) {
|
||||
waiting = true;
|
||||
} else if (connected && waiting) {
|
||||
location.href = '/';
|
||||
}
|
||||
});
|
||||
|
||||
// poll the server until it comes back online
|
||||
setInterval(
|
||||
() =>
|
||||
void getServerConfig()
|
||||
// eslint-disable-next-line no-self-assign
|
||||
.then(() => (location.href = location.href))
|
||||
.catch(() => {}),
|
||||
1000,
|
||||
);
|
||||
await endMaintenance();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue