feat(pwa): wire offline payment queueing into send flow, fix install/sync bugs - #647
Open
TheWeirdDee wants to merge 1 commit into
Open
feat(pwa): wire offline payment queueing into send flow, fix install/sync bugs#647TheWeirdDee wants to merge 1 commit into
TheWeirdDee wants to merge 1 commit into
Conversation
…bugs Builds on the PWA install-prompt and offline-queue infrastructure already merged from earlier issues (FinChippay#380, FinChippay#358, FinChippay#24) by closing the remaining gaps called out in FinChippay#388: - SendPaymentForm now actually queues a signed payment via offlineQueue when submitted while offline, instead of just failing. - Dashboard balance fetch now reads/writes through cacheData.ts (IndexedDB) so the offline snapshot has a real synced timestamp, in addition to the existing localStorage fallback. - New QueueSyncNotifier component toasts the result of each queued transaction once connectivity returns and the queue drains. - InstallPrompt's install-event tracking now actually reports through the app's existing Plausible-based analytics convention (lib/onboardingState.ts) instead of dispatching a CustomEvent with no listener. - OfflineBanner now consumes the (previously unused) useNetworkStatus hook instead of duplicating its own online/offline listeners. - Removed a redundant attachOnlineListener() call in _app.tsx that raced OfflineBanner's own online-transition handler against the same IndexedDB queue on every reconnect, which could double-submit a queued payment or cause a successful submission to be mislabeled "failed". - Service worker is now registered unconditionally on app load so install eligibility and offline caching are available before any user opts into push notifications. Closes FinChippay#388
Author
|
Closing — opened with unwanted AI-attribution text in the description that the author did not approve. |
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (8 file(s) changed). Review gates:
|
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.
Summary
Closes #388.
This repo's
mainalready carries PWA install-prompt and offline-queue infrastructure merged from earlier issues (#380, #358, #24) —InstallPrompt.tsx,lib/offlineQueue.ts,lib/cacheData.ts, andhooks/useNetworkStatus.tsall predate this PR. What was still missing against #388's acceptance criteria was wiring that infrastructure into the actual payment flow and fixing a few bugs left over from that work:SendPaymentFormnow actually callsqueueTransaction()when a signed payment is submitted while offline, instead of just letting the submission fail.dashboard.tsxbalance fetch now reads/writes throughcacheData.ts(IndexedDB) in addition to the existing localStorage snapshot, so the offline banner has a real synced timestamp to show.QueueSyncNotifiercomponent toasts the result of each queued transaction once connectivity returns and the queue drains (success/failure per payment), listening both to the in-pageprocessQueue()path and the service worker'sQUEUE_PROCESSEDmessage.InstallPrompt's install-event tracking previously dispatched aCustomEventwith no listener anywhere, so "installation events are tracked" wasn't actually true — now routed through the app's existing Plausible-based analytics convention (matcheslib/onboardingState.ts'strackOnboardingEvent).OfflineBannernow consumes theuseNetworkStatushook (previously created per spec but never imported anywhere) instead of duplicating its ownonline/offlinelisteners._app.tsxwas callingattachOnlineListener()on mount, which registers a secondonlinelistener that independently callsprocessQueue(). SinceOfflineBanner(mounted app-wide) already reacts to the same event via Background Sync or its ownprocessQueue()fallback, two listeners could race against the same IndexedDB queue on reconnect — in the worst case double-submitting a queued payment, or causing a successful submission to get mislabeled"failed"when the losing racer's resubmission is rejected by Horizon for a stale sequence number. Removed the redundant call;OfflineBanneralready owns this correctly._app.tsx) rather than only on-demand via the push-notification opt-in flow, so install eligibility and offline caching are available from first load.Test plan
npx tsc --noEmit— no new errors introduced (diffed against cleanmainbaseline; all remaining errors are pre-existing and unrelated)npx eslinton all touched files — clean__tests__/offlineQueue.test.ts— passes (oneattachOnlineListenertest is flaky on cleanmaintoo, unrelated to this change)