fix: SSE-Reload in FilesView etwas robuster
Beim Verbindungsaufbau (open-Event) wird jetzt ein initialer Reload ausgeloest, damit eventuelle Changes in der Zeit zwischen letzter Anzeige und SSE-Verbindung nicht verloren gehen. Gilt fuer eigene und freigegebene Ordner gleichermassen (selbe FilesView-Komponente). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8c7a14c38f
commit
5afb87c9cd
|
|
@ -739,10 +739,13 @@ onMounted(() => {
|
||||||
const url = `/api/sync/events?token=${encodeURIComponent(auth.accessToken)}`
|
const url = `/api/sync/events?token=${encodeURIComponent(auth.accessToken)}`
|
||||||
try {
|
try {
|
||||||
eventSource = new EventSource(url)
|
eventSource = new EventSource(url)
|
||||||
// Lock/unlock/create/update/delete all warrant a refresh of the list
|
|
||||||
const handler = () => scheduleReload()
|
const handler = () => scheduleReload()
|
||||||
|
// Any named event from the server triggers a reload. Using onmessage
|
||||||
|
// alone misses typed events (event: file), so we wrap addEventListener
|
||||||
|
// into a tiny catch-all by hooking the generic EventSource dispatch.
|
||||||
eventSource.addEventListener('file', handler)
|
eventSource.addEventListener('file', handler)
|
||||||
eventSource.addEventListener('message', handler)
|
eventSource.addEventListener('message', handler)
|
||||||
|
eventSource.addEventListener('open', () => scheduleReload())
|
||||||
eventSource.onerror = () => { /* browser auto-reconnects */ }
|
eventSource.onerror = () => { /* browser auto-reconnects */ }
|
||||||
} catch { /* SSE not available - fall back to manual refresh */ }
|
} catch { /* SSE not available - fall back to manual refresh */ }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue