-
Notifications
You must be signed in to change notification settings - Fork 299
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
Amir/feq 307/remove extra active symbols request #9176
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-amir-deriv-amir-feq-307remove-extra-a-a4cf21.binary.sx/ |
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
* from server since this is getting called in chart init and | ||
* active_symbols is already being fetched in trade.jsx init | ||
*/ | ||
return null; |
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.
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.
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.
Maybe we can return this.active_symbols
instead? 🤔
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.
Done 🙏
const useActiveSymbols = (mode?: 'brief' | 'full') => { | ||
const res = useFetch('active_symbols', { | ||
payload: { | ||
active_symbols: mode || 'brief', | ||
}, | ||
options: { | ||
refetchOnWindowFocus: false, | ||
}, | ||
}); | ||
|
||
return res; | ||
}; |
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.
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.
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.
@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
…q-307/remove-extra-active-symbols-request
…thub.com:amir-deriv/deriv-app into amir/feq-307/remove-extra-active-symbols-request
@farzin-deriv @maryia-deriv comments are resolved🙏 |
…q-307/remove-extra-active-symbols-request
…thub.com:amir-deriv/deriv-app into amir/feq-307/remove-extra-active-symbols-request
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
import { useMemo } from 'react'; | ||
|
||
/** A custom hook to get the list of active symbols. */ | ||
const useActiveSymbols = () => { |
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.
Please take look the issue that "active_symbol" not been updated after switching language, Thanks
…q-307/remove-extra-active-symbols-request
|
GitGuardian id | Secret | Commit | Filename | |
---|---|---|---|---|
- | Generic High Entropy Secret | 2ec1d1c | nx.json | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- 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
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 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!
…q-307/remove-extra-active-symbols-request
…q-307/remove-extra-active-symbols-request
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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 foractive_symbols
in dTraderScreenshots:
Please provide some screenshots of the change.