Repository navigation
feat(requests): apply live payment request updates, persist requestedPayment - #1158
Merged
Merged
Conversation
Updates apply by version against the held copy: created merges like a fetched copy, a batch at L+1 applies in order, a gap or an update the copy can't apply refetches the request. The polls stay as reconciliation.
Stores Activity.requestedPayment in a joined requestedPayment table, the way boostedReaction is, so it survives a read from the database. Bumps Database.schemaVersion to 61.
Transaction details shows View Request for a payment that paid a share, ahead of the counterparty button and behind a boost. Request details shows a message instead of a spinner when the request is DENIED or NOT_FOUND. A status update with no closedAt keeps the held closedAt.
View Request in transaction details now opens the request's chat with Request details presented over it, as tapping the request in the chat does, instead of the details on their own. The unavailable message reads "This request is no longer available."
The ring sweep, the switch to the ended look and a share turning paid now animate (about 300 ms ease-out) when the value changes on a request already on screen, and not on first appearance. A re-sort caused by a request ending waits for that fade, then uses the deck's settle spring. Reduce Motion turns all of it off.
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.
Live request updates
ConversationStreamEvent.paymentRequestsChangednow reachesPaymentRequests, the store the deck, expanded list and Request details read, so a paid share or a close shows without waiting for the 45 s poll.ConversationControllerhands the event toPaymentRequests.apply(_:)(weak reference, set by the session) and refetches the ids it returns..createdgoes throughingest: greater version wins, EXPIRED over OPEN at equal version..updates(V)against a held copy at L is decided byGroupPaymentRequest.applying(version:updates:): V <= L ignored; V == L + 1 applies every change in order and sets the version; V > L + 1 refetches viaGetPaymentRequest. With no held copy the batch is dropped..unknownupdate, a share whose user the copy doesn't have, or a status other than COMPLETED/CLOSED applies nothing and refetches..sharePaidreplaces the share with the same user;.statusChangedsets status andclosedAt, keeping the heldclosedAtwhen the update carries none. Expiry stays a read-time judgement fromendsAt.Every refetch trigger in the spec's Refetching table and the polls are unchanged. Tests are in
PaymentRequestsLiveUpdateTests(one per branch, plus duplicate and out-of-order delivery).requestedPayment persistence
Activity.requestedPaymentis stored in a newrequestedPaymenttable joined 1:1 toactivity, the wayboostedReactionis, and read back by both activity queries.Database.schemaVersion60 -> 61; there are no migrations, the store is rebuilt from the server.Database+RequestedPaymentTestscovers round trip, nil, and a re-sync dropping the link.Transaction details link
A payment with
requestedPaymentshows a "View Request" button in the slotchatActionfills. A boost's "View Message" wins over it, and it wins over the counterparty's "View Profile" / "View in Chat". Heading and subtitle are unchanged.The button routes through
DeepLinkAction.routeChat: it opens the request's conversation and puts Request details on top, so closing the details lands in the chat. A closed request reads as closed there. A DENIED or NOT_FOUND fetch shows "This request is no longer available." instead of a spinner that never resolves.TransactionDetailsTestsD4 and D5 cover the choice of action.Motion
Changes to a request already on screen animate: the ring sweep (about 300 ms ease-out), the switch to the ended look (about 300 ms fade) and a share turning paid (fade).
animation(_:value:)skips first appearance, so nothing plays on load. A re-sort caused by a request ending waits for the fade, then uses the deck's settle spring. Reduce Motion applies every change at once. The modifier isrequestMotion(value:)inPaymentRequestRing.swift.