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 intoJul 27, 2026
Conversation
|
@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! 🚀 |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tshad no guard preventing multipleNotifications.addPushTokenListenerregistrations across app launches and background restores. Added a module-leveltokenExpirySubscriptionvariable and asetupTokenExpiryListener()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 tosetupForegroundBadgeSync()to prevent badge handlers from doubling up on re-launch.#813 — Request deduplication in RequestQueue
requestQueue.tsenqueued 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 afingerprint(config)method that hashesmethod + URL + bodyinto a deterministic key, stored asfingerprintonQueuedRequest.addToQueuenow 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 readsNetwork.getNetworkStateAsync()first:#824 — Offline mode banner
Added
src/components/common/OfflineBanner.tsx: anAnimatedbanner 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 torequestQueue.onPendingCountChangefor live queue depth. Accessible viaaccessibilityRole="alert"andaccessibilityLiveRegion="assertive".Files changed
src/services/pushNotifications.ts— token listener guard + skip-if-registered ([Performance] pushNotifications.ts token expiry listener accumulates on each app launch #812)src/services/api/requestQueue.ts— fingerprint-based deduplication ([Performance] requestQueue.ts has no request deduplication — identical mutations fire multiple times #813)src/services/cacheWarming.ts— network-quality gate ([Performance] warmCriticalCaches() ignores network quality — prefetches full data on slow connections #814)src/components/common/OfflineBanner.tsx— new offline indicator ([Enhancement] No offline mode indicator — users have no feedback when app is in degraded state #824)