Skip to content

feat: add offline banner and auto-retry indicator for failed API polling (#511)#682

Open
Amas-01 wants to merge 1 commit into
Junirezz:mainfrom
Amas-01:feature/offline-banner-retry-indicator
Open

feat: add offline banner and auto-retry indicator for failed API polling (#511)#682
Amas-01 wants to merge 1 commit into
Junirezz:mainfrom
Amas-01:feature/offline-banner-retry-indicator

Conversation

@Amas-01
Copy link
Copy Markdown
Contributor

@Amas-01 Amas-01 commented Jun 1, 2026

Pull Request: Add offline banner and auto-retry indicator for failed API polling

Closes #511

Summary

  • NEW: useNetworkStatus hook for browser connectivity detection

    • Subscribes to window online/offline events
    • Returns { isOnline: boolean }
    • Testable with fake timers and mocked navigator.onLine
  • NEW: useRetryState hook for tracking React Query retry cycles

    • Monitors query cache for error states
    • Computes seconds until next retry attempt
    • Returns { isRetrying: boolean, secondsUntilRetry: number | null }
  • ENHANCED: OfflineBanner component with retry countdown indicator

    • Offline state: Non-dismissible warning banner when device is offline
    • Retrying state: Shows countdown "Reconnecting... retrying in Xs"
    • Success state: Brief auto-dismissing success message on reconnection
    • Hidden state: Renders nothing when online and not retrying
    • ARIA attributes: role="alert" for offline (assertive), role="status" for retrying/success
  • UPDATED: Polling pause/resume for network awareness

    • useVaultData.ts: useVaultSummary(enabled: isOnline) pauses polling when offline
    • useFeeEstimate.ts: Added enabledNetworkPolling parameter for XLM price polling
    • useTvlTicker.ts: Added enabled parameter to pause TVL polling when offline
    • VaultContext.tsx: Passes isOnline to useVaultSummary
    • TvlTicker.tsx: Uses useNetworkStatus for polling control
    • VaultDashboard.tsx: Passes isOnline to useFeeEstimate
  • STYLING: Added .offline-banner--retrying variant (amber background)

    • Z-index: 1000 (above page content, below modals)
    • Auto-dismisses success after 4 seconds
    • Responsive layout with no text truncation
  • TESTS: Comprehensive unit tests

    • useNetworkStatus.test.ts: Online/offline transitions, event listener cleanup
    • useRetryState.test.ts: Query cache subscription, countdown logic
    • OfflineBanner.test.tsx: Enhanced tests for all banner states, ARIA attributes, icons

Polling implementations now pause automatically when device goes offline and resume on reconnection. Users see a clear offline banner and retry countdown, improving connectivity awareness without manual intervention.

…ing (Junirezz#511)

- NEW: useNetworkStatus hook for browser connectivity detection
  * Subscribes to window online/offline events
  * Returns { isOnline: boolean }
  * Testable with fake timers and mocked navigator.onLine

- NEW: useRetryState hook for tracking React Query retry cycles
  * Monitors query cache for error states
  * Computes seconds until next retry attempt
  * Returns { isRetrying: boolean, secondsUntilRetry: number | null }

- ENHANCED: OfflineBanner component with retry countdown indicator
  * Offline state: Non-dismissible warning banner when device is offline
  * Retrying state: Shows countdown "Reconnecting... retrying in Xs"
  * Success state: Brief auto-dismissing success message on reconnection
  * Hidden state: Renders nothing when online and not retrying
  * ARIA attributes: role="alert" for offline (assertive), role="status" for retrying/success

- UPDATED: Polling pause/resume for network awareness
  * useVaultData.ts: useVaultSummary(enabled: isOnline) pauses polling when offline
  * useFeeEstimate.ts: Added enabledNetworkPolling parameter for XLM price polling
  * useTvlTicker.ts: Added enabled parameter to pause TVL polling when offline
  * VaultContext.tsx: Passes isOnline to useVaultSummary
  * TvlTicker.tsx: Uses useNetworkStatus for polling control
  * VaultDashboard.tsx: Passes isOnline to useFeeEstimate

- STYLING: Added .offline-banner--retrying variant (amber background)
  * Z-index: 1000 (above page content, below modals)
  * Auto-dismisses success after 4 seconds
  * Responsive layout with no text truncation

- TESTS: Comprehensive unit tests
  * useNetworkStatus.test.ts: Online/offline transitions, event listener cleanup
  * useRetryState.test.ts: Query cache subscription, countdown logic
  * OfflineBanner.test.tsx: Enhanced tests for all banner states, ARIA attributes, icons

Polling implementations now pause automatically when device goes offline and resume
on reconnection. Users see a clear offline banner and retry countdown, improving
connectivity awareness without manual intervention.

Closes Junirezz#511
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@Amas-01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend: Add offline banner and auto-retry indicator for failed API polling

1 participant