-
Notifications
You must be signed in to change notification settings - Fork 5
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 asset update issue #1389
fix asset update issue #1389
Conversation
resolve - asset update issue based on time stamp and use spread - account chart extra refresh issue
WalkthroughThe updates primarily involve refining Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
packages/extension-polkagate/src/fullscreen/accountDetails/components/TotalChart.tsx (1)
Line range hint
49-49
: Consider using optional chaining for safer code.Based on the static analysis hint, employing optional chaining here can help avoid potential runtime errors when accessing nested properties.
- pricesInCurrency?.prices?.[priceId]?.value || 0 + pricesInCurrency?.prices?.[priceId]?.value ?? 0packages/extension-ui/src/Popup/index.tsx (1)
Line range hint
262-266
: Implement optional chaining to enhance code robustness.Use optional chaining to safely access nested properties and avoid potential runtime errors.
- getStorage('pricesInCurrencies') + getStorage('pricesInCurrencies')?.then(...) - delete (newPrices as Prices).currencyCode; + (newPrices as Prices)?.currencyCode = undefined;
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/extension-polkagate/src/fullscreen/accountDetails/components/TotalChart.tsx (1 hunks)
- packages/extension-ui/src/Popup/index.tsx (1 hunks)
Additional context used
Biome
packages/extension-polkagate/src/fullscreen/accountDetails/components/TotalChart.tsx
[error] 49-49: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
packages/extension-ui/src/Popup/index.tsx
[error] 189-189: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 262-262: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 264-264: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 266-266: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Additional comments not posted (2)
packages/extension-polkagate/src/fullscreen/accountDetails/components/TotalChart.tsx (1)
116-116
: OptimizeuseEffect
dependencies for performance.The update to use
assets?.length
instead ofassets
is a good approach, as it reduces unnecessary re-renders by only reacting to changes in the number of assets, not changes to the object itself.packages/extension-ui/src/Popup/index.tsx (1)
155-156
: Use spread syntax to efficiently update state.The use of spread syntax in
setAccountsAssets
ensures that the state updates incorporate all properties ofassetsOnChains
, which is crucial for maintaining the integrity of the state.
if (!found) { | ||
delete assetsOnChains.balances[_address]; | ||
setStorage(ASSETS_NAME_IN_STORAGE, assetsOnChains, true).catch(console.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.
Avoid using the delete operator for better performance.
Using the delete operator can lead to performance issues due to deoptimizations. Instead, set the property to undefined.
- delete assetsOnChains.balances[_address];
+ assetsOnChains.balances[_address] = undefined;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (!found) { | |
delete assetsOnChains.balances[_address]; | |
setStorage(ASSETS_NAME_IN_STORAGE, assetsOnChains, true).catch(console.error); | |
} | |
if (!found) { | |
assetsOnChains.balances[_address] = undefined; | |
setStorage(ASSETS_NAME_IN_STORAGE, assetsOnChains, true).catch(console.error); | |
} |
resolve
Summary by CodeRabbit