Repository navigation
feat(chat): apply real-time payment request updates and persist requestedPayment - #1877
Merged
Merged
Conversation
The ring sweeps to the new paid count over about 300 ms, a request that ends fades into its ended look, and a share fades to paid. Only value changes animate, and the deck holds its order while an animation runs.
The trigger lived in the message bubble, so it only fired for rows that were composed and keyed the dedupe on the request id, which dropped the second payment to the same request. ChatRequestsViewModel now watches the open chat's stored messages and calls PaymentRequests.refetch once per cash message sent after the chat opened.
The request card and Request details already show the payment, so the transcript draws no bubble for a cash message with a payment_request_id. The filter runs after paging, so keys and load-more still see the message. The chat list preview, unread count, arrival and divider queries skip it too, and a jump to its id lands on the nearest older drawn message.
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.
Apply
ChatUpdate.paymentRequestUpdatesto the chat's request store, and persistrequestedPaymentfrom activity feed notifications.Live updates.
EventStreamDelegatehands the stream's updates toPaymentRequeststhrough a newPaymentRequestUpdateSink(defaulted to a no-op so existing delegate construction is unchanged). The store applies them by version, perPaymentRequestUpdatein the proto:createdmerges like a fetched copy (greater version; EXPIRED over OPEN at a tie).updatesat V against held L: V <= L ignored; V == L + 1 applies every change in order and sets the version; V > L + 1 refetches the request.SharePaidreplaces the share with the sameuserIdand keeps the held amount.StatusChangedsets status andclosedAt. Expiry stays a read-time judgement fromendsAt.Version rules are covered by
PaymentRequestsUpdateTest.requestedPayment.
MessageMetadata.DirectlySentCryptoandReceivedCryptogain a defaultedrequestedPayment, andMetadataMappercopies it across. Metadata is stored in the existing JSON column, so no migration is needed and older rows decode it as null. Round-trip tests are inNotificationToEntityMapperTest.Link from transaction details. A payment with
requestedPaymentshows "View Request" in the slot "View Message" uses, replacing "View Profile" / "View in Chat". If a boost is also set, the boost wins. The button opens the payment's chat with Request details over it (AppRoute.Messaging.Chat.openRequestIdputsChatStep.RequestDetailson the flow's initial stack). The route is built from the stored snapshot and not validated: a closed request renders as closed, and when the fetch finds the request DENIED or NOT_FOUND with none held, Request details now shows "This request is no longer available." where it used to render blank. That message is new copy; there was no existing unavailable state on the details screen (the deck's unsupported card says the message needs a newer version, which does not fit).Payments that pay a request.
ChatRequestsViewModelwatches the open chat's stored messages (ChatCoordinator.observeMessages) and callsPaymentRequests.refetchonce per cash message that carries apaymentRequestIdand is dated after the chat opened. This replacesRefreshOnArrivalin the bubble, which fired only for composed rows and deduped per request id, so a second payment to the same request was dropped.PaymentArrivalsTestcovers the new-message, no-id, pre-open, repeat and two-messages-one-request cases.Share payment bubble. A cash message with a
paymentRequestIddraws no bubble, since the request card and Request details already show it. The filter runs on the mapped rows after paging (ChatViewModel,paysRequestShare), so keys and load-more still see the message. The chat list preview, unread count, arrival and divider queries inChatMessageDaoskip it with acontent_jsonmatch, and a jump to its id lands on the nearest older drawn message.