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.
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
feat(synapse-interface): refresh stale quotes #2607
feat(synapse-interface): refresh stale quotes #2607
Changes from 7 commits
3b2c21f
7807989
486aeab
491ddc4
bfe83d5
a9827ff
d8b0ece
223f0d7
fe2ee9f
938b3c2
e170678
f8fadd6
d29218d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the other deps in here?:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentTime
is the only dep we would want to react to in order to maintain quote freshness for thestaleTimeout
defined time intervals. Including the other deps may prematurely refresh the quote in this useEffectThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isValidQuote, isQuoteLoading, isWalletPending
: If I'm understanding this correctly, these flags determine if an event listener should be added? And we don't want to add them bc we don't want to re-attach if they change?quoteTime
: Is this the timestamp which staleness is calculated? Don't we need to include that bc ifquoteTime
changes, then the staleness logic needs to re-run?staleTimeout
: Is this the value that determines what's considered stale? So if it changes, the staleness logic would re-run here as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct,
isValidQuote, isQuoteLoading, isWalletPending
are used to determine if an event listener should be attached, but we don't want to react to these props because:isQuoteLoading
could cause for infinite re-renders - if new quote is being fetched for updated inputs, this would effectively re-trigger another quote fetchisValidQuote
may change frequently if the User is testing out various inputs (token / amount combos) and could effectively re-trigger a quote fetch before interval time has passedIncluding
quoteTime
would also cause infinite re-renders since the change inquoteTime
would cause for the quote to refresh in the background, which then updates thequoteTime
value again.Good catch on the
staleTimeout
! I originally expected forstaleTimeout
to be a static value when using the hook, but that's an improper assumption to make. Updated to includestaleTimeout
in the useEffect dependencies array in f8fadd6