Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(TransactionFeedV2): Trigger haptic feedback when pending transactions turn to completed #6154

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

sviderock
Copy link
Contributor

@sviderock sviderock commented Oct 14, 2024

Description

8th PR for RET-1207. Implements triggering of the haptic feedback when transactions turn from pending to completed.

Test plan

Added tests to validate the logic of triggering the haptic feedback

Related issues

Backwards compatibility

Yes

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.82%. Comparing base (204d407) to head (f03ec80).
Report is 1 commits behind head on slava/feed-v2-no-more-transactions-toast.

Files with missing lines Patch % Lines
src/transactions/feed/TransactionFeedV2.tsx 86.95% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                             Coverage Diff                              @@
##           slava/feed-v2-no-more-transactions-toast    #6154      +/-   ##
============================================================================
+ Coverage                                     88.77%   88.82%   +0.05%     
============================================================================
  Files                                           727      727              
  Lines                                         30791    30807      +16     
  Branches                                       5636     5328     -308     
============================================================================
+ Hits                                          27334    27365      +31     
+ Misses                                         3414     3399      -15     
  Partials                                         43       43              
Files with missing lines Coverage Δ
src/transactions/feed/TransactionFeedV2.tsx 91.86% <86.95%> (+1.47%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 204d407...f03ec80. Read the comment docs.

@sviderock sviderock changed the title chore(TransactionFeedV2): Add haptic feedback to newly completed transactions (WIP) chore(TransactionFeedV2): Add haptic feedback to newly completed transactions Oct 15, 2024
@sviderock sviderock marked this pull request as ready for review October 15, 2024 12:28

const flattenedTransactions = Object.values(
state.transactions.transactionsByNetworkId
).flat() as TokenTransaction[]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As transactionsByNetworkId were grouped by networkId - it should be safe to assume that Zerion can also return the same hash for two different networks, considering that it should return identical data to what we were getting with the previous data providers. I think I need to change the whole implementation of knownCompletedTransactionsHashes to maybe store keys like ${networkId}_${transactionHash} or an object just like transactionsByNetworkId but wanted to post this here to confirm. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think we should store just the first page with all networks combined.
But because we need to keep the old feed, this should be a new field in the reducer.

@sviderock sviderock changed the title chore(TransactionFeedV2): Add haptic feedback to newly completed transactions chore(TransactionFeedV2): Persist known completed transactions and add haptic feedback Oct 15, 2024
Comment on lines 388 to 395
useEffect(
function updateKnownCompletedTransactions() {
if (data?.transactions.length) {
dispatch(updateKnownCompletedTransactionsHashes(data.transactions))
}
},
[data?.transactions]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we could skip this effect by reacting to the underlying RTK-Query API fetched action, within the transactions reducer, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanregisser Will investigate and get back to you on this!


const flattenedTransactions = Object.values(
state.transactions.transactionsByNetworkId
).flat() as TokenTransaction[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think we should store just the first page with all networks combined.
But because we need to keep the old feed, this should be a new field in the reducer.

@@ -22,11 +22,13 @@ interface State {
// feed instantly.
standbyTransactions: StandbyTransaction[]
transactionsByNetworkId: TransactionsByNetworkId
knownCompletedTransactionsHashes: string[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a new transactions field to store the first page (or last X newest items) from the new API?
Then we could avoid the need for knownCompletedTransactionsHashes and use selectors to derive what we need from it.

Then if we see a new transaction that's newer than the oldest item in the newest list of items, we can vibrate.

This would address this new field proposed here being an ever growing list of TX hashes. And would serve the purpose of showing cached data directly on app load.

Would this all work?

@sviderock sviderock force-pushed the slava/feed-v2-vibrate-on-success branch from b6bb048 to e2cf8ff Compare October 16, 2024 14:12
@sviderock sviderock changed the title chore(TransactionFeedV2): Persist known completed transactions and add haptic feedback chore(TransactionFeedV2): Trigger haptic feedback when pending transactions turn to completed Oct 16, 2024
@sviderock
Copy link
Contributor Author

@jeanregisser The easiest way to remove the unnecessary redux changes in multiple files was just resetting the commits related to redux changes and force-pushing.

I've updated this PR to only implement haptic for newly completed transactions. I'll add haptic for new unknown completed transactions as a follow-up PR to this PR as it implements feedFirstPage which we can use for this exact thing.

Base automatically changed from slava/feed-v2-no-more-transactions-toast to main October 17, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants