Skip to content

perf: fix token listener accumulation, add request deduplication, network-aware cache warming, and offline banner (#812 #813 #814 #824) - #890

Merged
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
BigBen-7:fix/bigben7-performance-issues-812-813-814-824
Jul 27, 2026
Merged

perf: fix token listener accumulation, add request deduplication, network-aware cache warming, and offline banner (#812 #813 #814 #824)#890
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
BigBen-7:fix/bigben7-performance-issues-812-813-814-824

Conversation

@BigBen-7

@BigBen-7 BigBen-7 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Closes #812
Closes #813
Closes #814
Closes #824

Summary

Four performance and UX improvements addressing offline behaviour, startup efficiency, and duplicate request handling.

#812 — Token expiry listener accumulation
pushNotifications.ts had no guard preventing multiple Notifications.addPushTokenListener registrations across app launches and background restores. Added a module-level tokenExpirySubscription variable and a setupTokenExpiryListener() export that skips registration if a listener is already active (early-return instead of remove-and-readd). The same skip-if-registered pattern was applied to setupForegroundBadgeSync() to prevent badge handlers from doubling up on re-launch.

#813 — Request deduplication in RequestQueue
requestQueue.ts enqueued every call unconditionally, so submitting a form while offline multiple times (or processing the queue more than once) sent the same mutation to the backend multiple times. Added a fingerprint(config) method that hashes method + URL + body into a deterministic key, stored as fingerprint on QueuedRequest. addToQueue now checks for an existing entry with the same fingerprint before enqueuing, and returns the existing request's id when a duplicate is detected.

#814 — Network-aware cache warming
warmCriticalCaches() previously fetched all data unconditionally, causing multi-second startup latency on 2G/3G and potential data exhaustion. The function now reads Network.getNetworkStateAsync() first:

  • Offline: skipped entirely
  • Cellular (non-WiFi): minimal prefetch — courses only, user profile skipped
  • WiFi / OTHER: full prefetch (original behaviour)

#824 — Offline mode banner
Added src/components/common/OfflineBanner.tsx: an Animated banner that slides in from the top within 500 ms of going offline, shows the number of pending queued actions (e.g. "2 actions pending sync"), and slides out automatically on reconnection. Subscribes to requestQueue.onPendingCountChange for live queue depth. Accessible via accessibilityRole="alert" and accessibilityLiveRegion="assertive".

Files changed

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@BigBen-7 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

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 331e69c into rinafcode:main Jul 27, 2026
1 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment