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

Fix/reset output #1446

Merged
merged 2 commits into from
Oct 20, 2023
Merged

Fix/reset output #1446

merged 2 commits into from
Oct 20, 2023

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Oct 11, 2023

In the scenario that the user clears the Bridge Input amount around when bridge quotes are returned, this will fix any glitch where the output amount shows a bridge quote for a prior Input amount.

Summary by CodeRabbit

  • New Feature: Added a resetBridgeQuote action to the bridgeSlice reducer. This action allows the bridgeQuote state to be reset to its initial value, improving the user experience by ensuring that outdated or incorrect data is not displayed.
  • Refactor: Updated the bridge updater to import and use the resetBridgeQuote function. This change enhances the application's responsiveness by clearing the bridge quote when the input is empty, preventing confusion or errors caused by stale data.

a6cf17e670fc3032deae9c3b5f8656a8f3a96f1c: synapse-interface preview link

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 11, 2023

Walkthrough

The changes introduced in this pull request primarily focus on enhancing the functionality of the bridgeSlice reducer in the Synapse Interface. A new action, resetBridgeQuote, has been added to reset the bridgeQuote state. Additionally, an effect has been introduced to clear the bridge quote when the input is empty.

Changes

File Summary
.../slices/bridge/reducer.ts Added a new action resetBridgeQuote to reset the bridgeQuote state.
.../slices/bridge/updater.tsx Imported resetBridgeQuote function and added a useEffect hook to clear the bridge quote if the input is empty.

🐇

"In the land of code, where logic is the road,

Changes small and wide, in this pull request reside.

A slice of bridge, a quote reset,

A cleaner input, as good as it gets! 🎉"


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 2ee5234 and 99bff1f.
Files selected for processing (2)
  • packages/synapse-interface/slices/bridge/reducer.ts (2 hunks)
  • packages/synapse-interface/slices/bridge/updater.tsx (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/slices/bridge/reducer.ts
Additional comments (Suppressed): 3
packages/synapse-interface/slices/bridge/updater.tsx (3)
  • 13-13: The resetBridgeQuote function is imported from reducer.ts. This function is used to reset the bridgeQuote state to its initial value when the input is empty.

  • 29-29: The bridgeQuote variable is added to the destructured variables from useBridgeState(). This variable represents the current bridge quote state.

  • 112-116: A new useEffect hook is introduced. This hook triggers the resetBridgeQuote function when the debouncedFromValue is equal to its initial state, effectively clearing the bridge quote when the input is empty. This is a good approach to prevent the display of outdated quotes when the input is cleared. However, please verify that the resetBridgeQuote function correctly resets the bridgeQuote state to its initial value.

+  // Clear bridge quote if input is empty
+  useEffect(() => {
+    if (debouncedFromValue === initialState.debouncedFromValue) {
+      dispatch(resetBridgeQuote())
+    }
+  }, [debouncedFromValue, bridgeQuote])

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (2ee5234) 50.69210% compared to head (99bff1f) 50.69210%.

Additional details and impacted files
@@              Coverage Diff              @@
##              master       #1446   +/-   ##
=============================================
  Coverage   50.69210%   50.69210%           
=============================================
  Files            356         356           
  Lines          24274       24274           
  Branches         267         267           
=============================================
  Hits           12305       12305           
  Misses         10775       10775           
  Partials        1194        1194           
Flag Coverage Δ
packages 90.62003% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bigboydiamonds bigboydiamonds merged commit 0304b1b into master Oct 20, 2023
42 checks passed
@bigboydiamonds bigboydiamonds deleted the fix/reset-output branch October 20, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants