mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Fix: Splashscreen Idle & Dev
This commit is contained in:
@@ -142,20 +142,38 @@
|
||||
if (appState.status === 'booting') splashDismissed = false
|
||||
})
|
||||
|
||||
let idleSplashLocked = false
|
||||
|
||||
function showIdleSplash() {
|
||||
if (idleSplashLocked || appState.idleSplash) return
|
||||
appState.idleSplash = true
|
||||
}
|
||||
let idleTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let idleDismissLock = false
|
||||
|
||||
function onIdleDismiss() {
|
||||
if (idleSplashLocked) return
|
||||
idleSplashLocked = true
|
||||
if (idleDismissLock) return
|
||||
idleDismissLock = true
|
||||
appState.idleSplash = false
|
||||
setTimeout(() => { idleSplashLocked = false }, 400)
|
||||
setTimeout(() => { idleDismissLock = false }, 400)
|
||||
}
|
||||
|
||||
function armIdleTimer() {
|
||||
if (idleTimer !== null) clearTimeout(idleTimer)
|
||||
const mins = settingsState.settings.idleTimeoutMin ?? 5
|
||||
if (mins <= 0) return
|
||||
idleTimer = setTimeout(() => {
|
||||
if (appState.status === 'ready' && !appState.idleSplash) appState.idleSplash = true
|
||||
}, mins * 60_000)
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (appState.status !== 'ready') return
|
||||
|
||||
const events = ['mousemove', 'mousedown', 'keydown', 'touchstart', 'touchmove', 'wheel', 'click'] as const
|
||||
for (const e of events) document.addEventListener(e, armIdleTimer, { capture: true, passive: true })
|
||||
armIdleTimer()
|
||||
|
||||
return () => {
|
||||
if (idleTimer !== null) { clearTimeout(idleTimer); idleTimer = null }
|
||||
for (const e of events) document.removeEventListener(e, armIdleTimer, { capture: true })
|
||||
}
|
||||
})
|
||||
|
||||
function onSplashRetry() {
|
||||
import('$lib/state/boot.svelte').then(({ retryBoot }) => {
|
||||
retryBoot(appState.authMode ?? 'NONE', appState.authUser ?? '', appState.authPass ?? '')
|
||||
@@ -187,6 +205,10 @@
|
||||
<SplashScreen mode="idle" showCards={settingsState.settings.splashCards ?? true} onDismiss={onIdleDismiss} />
|
||||
{/if}
|
||||
|
||||
{#if appState.devSplash}
|
||||
<SplashScreen mode="idle" showDevOverlay onDismiss={() => appState.devSplash = false} />
|
||||
{/if}
|
||||
|
||||
{#if showApp}
|
||||
{#if strippedLayout}
|
||||
{@render children()}
|
||||
|
||||
Reference in New Issue
Block a user