Skip to content

Conversation

@sergei-deriv
Copy link
Contributor

Changes:

Add keepPreviousData to useAuthorize hook. When the endpoint accounts_list will be created and separated from authorize request then we can move keepPreviousData property to the new hook.

You can read about keepPreviousData property here

Video:

[Desktop]

How it was:

Desktop.Loading.when.switching.between.wallets.mov

How it now:

Desktop.Without.loading.mov

[Responsive]

How it was:

Responsive.Loading.when.swithes.between.wallets.mov

How it now:

Responsive.Without.loading.mov

@vercel
Copy link

vercel bot commented Nov 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
deriv-app ✅ Ready (Inspect) Visit Preview Nov 2, 2023 11:02am

@sergei-deriv sergei-deriv changed the title [Wallets] Sergei / Suggestion to void loading when the user switches between wallets [Wallets] Sergei / Suggestion to avoid loading when the user switches between wallets Nov 2, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
3.7% 3.7% Duplication

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2023

A production App ID was automatically generated for this PR. (log)

Click here to copy & paste above information.
- **PR**: [https://github.com/binary-com/deriv-app/pull/11139](https://github.com/binary-com/deriv-app/pull/11139)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-sergei-deriv-sergei-suggestion-to-avo-12b8e9.binary.sx?qa_server=red.derivws.com&app_id=30366
    - **Original**: https://deriv-app-git-fork-sergei-deriv-sergei-suggestion-to-avo-12b8e9.binary.sx
- **App ID**: `30366`

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2023

🚀 Smoke test run (2) passed successfully!

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2023

🚨 Lighthouse report for the changes in this PR:

Category Score
🔺 Performance 15
🟧 Accessibility 75
🟢 Best practices 92
🟧 SEO 85
🟧 PWA 80

Lighthouse ran with https://deriv-app-git-fork-sergei-deriv-sergei-suggestion-to-avo-12b8e9.binary.sx/

const { data, ...rest } = useQuery('authorize', {
payload: { authorize: current_token || '' },
options: { enabled: Boolean(current_token) },
options: { enabled: Boolean(current_token), keepPreviousData: true },
Copy link

Choose a reason for hiding this comment

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

does this have effects only on wallets, or is it used elsewhere too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wojciech-deriv as I know we are using useQuery just for wallets package now. Anyway, I'm pretty sure this keepPreviousData can't break anything, it's just for UI

image

Copy link

Choose a reason for hiding this comment

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

could it cause a component to use stale data from previous authorisation e.g. while submitting a transfer, or reseting a balance, in case of new authorisation data being delayed/erorrer (e.g. poor network connection, which is common among our customers). E.g. lets say that navigation worked correctly and moved on to new route/component, but authorisation is still providing stale data from previous account.

I think best way to go would be to somehow explicitly support loading and error state - at least it ensures no weird edge cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Had a thought to add this before, and farzin was saying better not to hide the actual problem. I think multiple authorization could solve this issue https://app.clickup.com/t/20696747/PLA-623

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wojciech-deriv Understood your point, didn't think about this before. I'm not sure it could be a problem in our project, but we don't need to risk. Anyway, we can add this property to the hook which works with account_list endpoint when it will be created by BE team, but for now maybe would be better leave it as it now.

@farhan-nurzi-deriv yeah, hope this issue will be solved by this solution, thank you!

ghost
ghost previously approved these changes Nov 3, 2023
@ghost ghost dismissed their stale review November 7, 2023 08:56

realised some risks with that approach

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