-
Notifications
You must be signed in to change notification settings - Fork 985
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
wallet - reset input on send flow when swapping accounts #20099
Conversation
@@ -40,7 +40,6 @@ | |||
[:catn | |||
[:props | |||
[:map {:closed true} | |||
[:theme :schema.common/theme] |
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.
there was a schema issue as this now uses the context api internally
:label (i18n/label :t/import-private-key) | ||
:on-press (when (ff/enabled? ::wallet.import-private-key) | ||
#(rf/dispatch [:navigate-to :screen/wallet.import-private-key]))}]]]) | ||
(when (ff/enabled? ::wallet.import-private-key) |
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.
hide this button until it's a complete flow
@@ -91,15 +90,15 @@ | |||
[rn/view | |||
[quo/icon :i/alert | |||
{:size 16 | |||
:color colors/danger-50}]] | |||
:color (colors/resolve-color :danger theme)}]] |
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.
color system 👍
loading-routes? (rf/sub | ||
[:wallet/wallet-send-loading-suggested-routes?]) | ||
bottom (safe-area/get-bottom) | ||
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?) |
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.
before this page was mixing reagent and react - no bueno :)
(rn/use-effect | ||
(fn [] | ||
(set-input-state controlled-input/init-state)) | ||
[current-address]) |
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.
This hook flushes the input to it's default state once the current address changes
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.
checks it is not the default value as otherwise it causes a bug on the initial render. Only want this to fire if the account has changed and the input is not the initial state.
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.
Hey @J-Son89, what happens if we have routes shown on the screen, and we change the account, are routes cleaned too?
If not, probably we should call (rf/dispatch [:wallet/clean-suggested-routes])
here too.
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.
Thanks @briansztamfater gonna check this!
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.
Just noticed this while testing in one of my rebased branches:
If user disables a network and then the account changes, the disabled networks are not reset. I think we should reset disabled networks as well because the switched account might have balance only on the previously disabled networks, leading the user to a dead-end.
For that, we should call (rf/dispatch [:wallet/clean-disabled-from-networks])
here too. We can raise a new PR for this, let me know how would you like to handle it @J-Son89!
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.
Nice one @briansztamfater ! I can add the pr for this next week 👍
receiver-preferred-networks-set | ||
receiver-selected-network)) | ||
receiver-networks)) | ||
current-address (rf/sub [:wallet/current-viewing-account-address]) |
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.
current address sub added 👍
Jenkins BuildsClick to see older builds (36)
|
@@ -8,8 +8,7 @@ | |||
(h/render-with-theme-provider component :light)) | |||
|
|||
(def props | |||
{:theme :light |
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.
schema error
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.
lgtm!
(when (not= input-state controlled-input/init-state) | ||
(set-input-state controlled-input/init-state))) | ||
[current-address]) | ||
|
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.
Empty line
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.
will clean 👍
(rn/use-effect | ||
(fn [] | ||
(when (not= input-state controlled-input/init-state) | ||
(set-input-state controlled-input/init-state))) | ||
[current-address]) |
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.
I know when current-address
changes, the input-state
value in the callback would also be updated. But I think for correctness, we can use the value for input-state
from the callback for setState in set-input-state
.
That would be something like this:
(rn/use-effect
(fn []
(set-input-state #(if (= % controlled-input/init-state)
%
controlled-input/init-state)))
[current-address])
What do you think?
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.
yeah makes sense, (just as a nit I'll use a fn
so that I name the value prev-state
so it's very clear. but overall sounds good to me! :)
thanks!
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.
actually looking at this, I'm not sure it really makes sense.
Both will set the state to init/state. I don't want to trigger any state change if the initial value is already set that way. What you are suggesting here is a bit different, no?
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.
When you return the same value that was in the prev state, it doesn't trigger an update, because the reference stays the same. So the only time a state update is triggered is in the second case where the previous value is not equal to init-state.
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.
true, I forgot about that. Anyway, I updated the function to take a different approach and it clears it safely now 👍
d7f3e46
to
01a8258
Compare
85% of end-end tests have passed
Failed tests (6)Click to expandClass TestActivityCenterContactRequestMultipleDevicePR:
Class TestWalletOneDevice:
Class TestWalletMultipleDevice:
Class TestGroupChatMultipleDeviceMergedNewUI:
Expected to fail tests (2)Click to expandClass TestCommunityOneDeviceMerged:
Class TestGroupChatMultipleDeviceMergedNewUI:
Passed tests (44)Click to expandClass TestOneToOneChatMultipleSharedDevicesNewUiTwo:
Class TestCommunityMultipleDeviceMergedTwo:
Class TestCommunityOneDeviceMerged:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestActivityMultipleDevicePR:
Class TestActivityCenterContactRequestMultipleDevicePR:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestDeepLinksOneDevice:
Class TestWalletOneDevice:
Class TestActivityMultipleDevicePRTwo:
Class TestCommunityMultipleDeviceMerged:
|
@mariia-skrypnyk - I see you are testing this pr. There was conflicts so I rebased and pushed the changes up 👍 |
Thanks @J-Son89 🙏🥹 |
33% of end-end tests have passed
Failed tests (3)Click to expandClass TestWalletMultipleDevice:
Class TestWalletOneDevice:
Expected to fail tests (1)Click to expandClass TestGroupChatMultipleDeviceMergedNewUI:
Passed tests (2)Click to expandClass TestActivityCenterContactRequestMultipleDevicePR:
|
Hey @J-Son89 ! Thanks for your PR. |
fixes: #20100
In the sending flows, This pr updates the input amount page after switching account with the account switcher so that the input and related values will be flushed.
Screen.Recording.2024-05-20.at.11.17.15.mov
This pr also Hides the "Import Private Key" Flow from the user as the button was previously viewable and pressable but feature flagged.
Testing notes: this should also work on the bridging flows as well.