mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: prevent sync banner from flashing on session switches
Added isFirstConnectRef to distinguish between first SSE connection (page load) and subsequent reconnects (session switches). Only the first connection forces the banner to show; subsequent connects use non-forced mode which only displays the banner when returning from background within 30s, eliminating unwanted banner flashes on session changes.
This commit is contained in:
+11
-1
@@ -88,11 +88,21 @@ export function App() {
|
||||
const selectedSessionId = sessionMatch ? sessionMatch.sessionId : null
|
||||
const { isSyncing, startSync, endSync } = useSyncingState()
|
||||
const syncTokenRef = useRef(0)
|
||||
const isFirstConnectRef = useRef(true)
|
||||
|
||||
const handleSseConnect = useCallback(() => {
|
||||
// Increment token to track this specific connection
|
||||
const token = ++syncTokenRef.current
|
||||
startSync({ force: true })
|
||||
|
||||
// Only force show banner on first connect (page load)
|
||||
// Subsequent connects (session switches) use non-forced mode
|
||||
// which only shows banner when returning from background
|
||||
if (isFirstConnectRef.current) {
|
||||
isFirstConnectRef.current = false
|
||||
startSync({ force: true })
|
||||
} else {
|
||||
startSync()
|
||||
}
|
||||
const invalidations = [
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.sessions }),
|
||||
...(selectedSessionId ? [
|
||||
|
||||
Reference in New Issue
Block a user