Multiple minor changes and improvements
This commit is contained in:
@@ -6,13 +6,22 @@
|
||||
import Resume from './routes/Resume.svelte';
|
||||
import Settings from './routes/Settings.svelte';
|
||||
import Today from './routes/Today.svelte';
|
||||
import DayDetails from './routes/DayDetails.svelte';
|
||||
import Automations from './routes/Automations.svelte';
|
||||
import NonWorkingSettings from './routes/NonWorkingSettings.svelte';
|
||||
import Stats from './routes/Stats.svelte';
|
||||
|
||||
let ready = $state(false);
|
||||
let bootError = $state('');
|
||||
let retry = $state(0);
|
||||
async function tick() { try { await reconcile(); } catch (error) { bootError = `Actualisation impossible : ${error.message}`; } }
|
||||
|
||||
$effect(() => {
|
||||
retry;
|
||||
bootError = '';
|
||||
let alive = true;
|
||||
(async () => {
|
||||
try {
|
||||
await loadSettings();
|
||||
if (import.meta.env.DEV) {
|
||||
const { installDevSeed } = await import('./lib/seed.js');
|
||||
@@ -20,14 +29,15 @@
|
||||
}
|
||||
await reconcile();
|
||||
if (alive) ready = true;
|
||||
} catch (error) { if (alive) bootError = `Accès aux données impossible : ${error.message}`; }
|
||||
})();
|
||||
return () => (alive = false);
|
||||
});
|
||||
|
||||
// Time drives this app, so the clock is polled rather than waited on.
|
||||
$effect(() => {
|
||||
const id = setInterval(() => reconcile(), 30_000);
|
||||
const onVisible = () => document.visibilityState === 'visible' && reconcile();
|
||||
const id = setInterval(tick, 30_000);
|
||||
const onVisible = () => document.visibilityState === 'visible' && tick();
|
||||
document.addEventListener('visibilitychange', onVisible);
|
||||
return () => {
|
||||
clearInterval(id);
|
||||
@@ -40,7 +50,7 @@
|
||||
</script>
|
||||
|
||||
{#if !ready}
|
||||
<div class="boot"><p>Chargement…</p></div>
|
||||
<div class="boot">{#if bootError}<div class="stack"><p role="alert">{bootError}</p><button onclick={() => (retry += 1)}>Réessayer</button></div>{:else}<p>Chargement…</p>{/if}</div>
|
||||
{:else}
|
||||
{#if needsRefresh.value && !dayState.day}
|
||||
<!-- Only offered while no day is running, so an update can never interrupt
|
||||
@@ -51,7 +61,14 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if view === 'settings'}
|
||||
{#if bootError}<p role="alert">{bootError}</p><button onclick={tick}>Réessayer</button>{/if}
|
||||
{#if view === 'details'}
|
||||
<DayDetails />
|
||||
{:else if view === 'automations'}
|
||||
<Automations />
|
||||
{:else if view === 'non-working'}
|
||||
<NonWorkingSettings />
|
||||
{:else if ['settings', 'automations', 'non-working'].includes(view)}
|
||||
<Settings />
|
||||
{:else if view === 'today'}
|
||||
<Today />
|
||||
@@ -64,7 +81,7 @@
|
||||
<nav class:with-stats={view === 'stats'}>
|
||||
<button
|
||||
type="button"
|
||||
class:sel={view === 'resume'}
|
||||
class:sel={['resume', 'details'].includes(view)}
|
||||
disabled={dayState.importing}
|
||||
aria-current={view === 'resume'}
|
||||
onclick={() => go('resume')}>Récap</button
|
||||
@@ -78,9 +95,9 @@
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class:sel={view === 'settings'}
|
||||
class:sel={['settings', 'automations', 'non-working'].includes(view)}
|
||||
disabled={dayState.importing}
|
||||
aria-current={view === 'settings'}
|
||||
aria-current={['settings', 'automations', 'non-working'].includes(view)}
|
||||
onclick={() => go('settings')}>Réglages</button
|
||||
>
|
||||
{#if view === 'stats'}
|
||||
|
||||
Reference in New Issue
Block a user