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

Amir/feq 307/remove extra active symbols request #9176

Conversation

amir-deriv
Copy link
Contributor

@amir-deriv amir-deriv commented Jun 28, 2023

Changes:

There were 4 extra api calls to active_symbols in the dTrader homepage, the changes in PR removes those extra calls and now it's only 1 api call to the server for active_symbols in dTrader

Screenshots:

Please provide some screenshots of the change.

@vercel
Copy link

vercel bot commented Jun 28, 2023

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

Name Status Preview Comments Updated (UTC)
deriv-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 6, 2023 5:13pm

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 2023

🚨 Lighthouse report for the changes in this PR:

Category Score
🔺 Performance 16
🟧 Accessibility 75
🟢 Best practices 92
🟧 SEO 85
🟢 PWA 90

Lighthouse ran with https://deriv-app-git-fork-amir-deriv-amir-feq-307remove-extra-a-a4cf21.binary.sx/

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 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/9176](https://github.com/binary-com/deriv-app/pull/9176)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-amir-deriv-amir-feq-307remove-extra-a-a4cf21.binary.sx?qa_server=red.binaryws.com&app_id=32205
    - **Original**: https://deriv-app-git-fork-amir-deriv-amir-feq-307remove-extra-a-a4cf21.binary.sx
- **App ID**: `32205`

@coveralls
Copy link

coveralls commented Jul 3, 2023

Coverage Status

coverage: 9.773% (-0.005%) from 9.778% when pulling c529b8c on amir-deriv:amir/feq-307/remove-extra-active-symbols-request into 381d126 on binary-com:master.

* from server since this is getting called in chart init and
* active_symbols is already being fetched in trade.jsx init
*/
return null;
Copy link
Contributor

@maryia-deriv maryia-deriv Jul 3, 2023

Choose a reason for hiding this comment

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

wsSendRequest is passed into SmartCharts as requestAPI callback so that it can request active_symbols (via deriv-app here), so active symbols (e.g. this.active_symbols) have to be returned here instead of null. Otherwise, SmartCharts won't get active symbols. please check this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can return this.active_symbols instead? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 🙏

Comment on lines 3 to 14
const useActiveSymbols = (mode?: 'brief' | 'full') => {
const res = useFetch('active_symbols', {
payload: {
active_symbols: mode || 'brief',
},
options: {
refetchOnWindowFocus: false,
},
});

return res;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const useActiveSymbols = (mode?: 'brief' | 'full') => {
const res = useFetch('active_symbols', {
payload: {
active_symbols: mode || 'brief',
},
options: {
refetchOnWindowFocus: false,
},
});
return res;
};
/** A custom hook to get the list of active symbols. */
const useActiveSymbols = () => {
const { data, ...rest } = useFetch('active_symbols', { payload: { active_symbols: 'brief' } });
const active_symbols = useMemo(
() =>
data?.active_symbols?.map(symbol => ({
...symbol,
/** The icon name for the underlying asset. */
icon: `IcUnderlying${symbol.symbol}`,
})),
[data?.active_symbols]
);
return {
/** List of active symbols. */
data: active_symbols,
...rest,
};
};

@amir-deriv Let's have the data transformation layer, Later trader team can make use of it based on their need since we are not aware of the requirements but we can give them the abstraction to start with.

Copy link
Contributor

Choose a reason for hiding this comment

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

@maryia-deriv Just a heads-up of what's coming, Later trader team can start using this hook to get the active symbols only where it's needed inside the component lifecycle, By doing so you guys will be able to remove the related stores and logic inside of it. What @amir-deriv has done here is just pass the data from the hook to the existing stores since we can't make big breaking changes in one go and we need help from the trader team who knows the business.

That icon thing above is just an example of how we can transform BE response based on our need in a centralized top-level place, This helps to remove lots of small conditions in the codebase and make it easier to maintain changes. You can also have a look at the useCurrencyConfig hook for more examples, If still confusing let me know to have a talk 🙇🏻

cc: @matin-deriv

…thub.com:amir-deriv/deriv-app into amir/feq-307/remove-extra-active-symbols-request
@amir-deriv
Copy link
Contributor Author

@farzin-deriv @maryia-deriv comments are resolved🙏

maryia-deriv
maryia-deriv previously approved these changes Jul 4, 2023
…thub.com:amir-deriv/deriv-app into amir/feq-307/remove-extra-active-symbols-request
@sonarcloud
Copy link

sonarcloud bot commented Aug 24, 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 0 Code Smells

No Coverage information No Coverage information
3.0% 3.0% Duplication

import { useMemo } from 'react';

/** A custom hook to get the list of active symbols. */
const useActiveSymbols = () => {

Choose a reason for hiding this comment

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

Please take look the issue that "active_symbol" not been updated after switching language, Thanks

@gitguardian
Copy link

gitguardian bot commented Oct 6, 2023

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
- Generic High Entropy Secret 2ec1d1c nx.json View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@sonarcloud
Copy link

sonarcloud bot commented Oct 6, 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 5 Code Smells

No Coverage information No Coverage information
7.2% 7.2% Duplication

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.

10 participants