-
Notifications
You must be signed in to change notification settings - Fork 74
Performance: optimizations #3094
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
base: development
Are you sure you want to change the base?
Conversation
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: 0
🧹 Nitpick comments (3)
src/containers/pointsContainer.ts (2)
260-260: Prefer the existingselectCurrentAccountNameselector.Line 260 calls
selectCurrentAccount(state).name, which directly accesses a property after calling the selector. For consistency with the PR's goal and better null-safety, use the existingselectCurrentAccountNameselector.🔎 Proposed fix
+ selectCurrentAccountName, selectOtherAccounts,user: selectCurrentAccount(state), - username: selectCurrentAccount(state).name, + username: selectCurrentAccountName(state), activeBottomTab: selectActiveBottomTab(state),
268-268: Consider creating a dedicated selector for the currency property.Line 268 accesses
selectCurrency(state).currency, which reaches into the returned object. For consistency with the selector pattern used elsewhere (e.g.,selectCurrencyRate,selectCurrencySymbol), consider adding a dedicated selector in the selectors file that returns just the currency string.src/screens/application/container/applicationContainer.tsx (1)
950-954: Incomplete selector migration for UI state.Lines 950-954 still use direct state access. For consistency with the PR's goal and the rest of this file, consider:
- Line 952:
activeBottomTabcould use the existingselectActiveBottomTabselector (defined at line 272 of selectors file).- Lines 951, 953, 954:
toastNotification,isLogingOut, andrcOfferdon't have corresponding selectors yet. Consider adding them to complete the migration.🔎 Proposed fix for activeBottomTab
Add to imports at line 104:
selectCurrentAccountUnreadActivityCount, + selectActiveBottomTab, } from '../../../redux/selectors';Update mapStateToProps:
// UI toastNotification: state.ui.toastNotification, - activeBottomTab: state.ui.activeBottomTab, + activeBottomTab: selectActiveBottomTab(state), isLogingOut: state.ui.isLogingOut,
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/components/editorElements/selectCommunityModal/container/selectCommunityModalContainer.tsxsrc/containers/pointsContainer.tssrc/containers/redeemContainer.tsxsrc/redux/selectors/index.tssrc/screens/application/container/applicationContainer.tsxsrc/screens/searchResult/screen/tabs/topics/container/topicsResultsContainer.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/components/editorElements/selectCommunityModal/container/selectCommunityModalContainer.tsx
- src/containers/redeemContainer.tsx
- src/screens/searchResult/screen/tabs/topics/container/topicsResultsContainer.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/containers/pointsContainer.ts (1)
src/redux/selectors/index.ts (8)
selectCurrentAccount(167-170)selectActiveBottomTab(272-272)selectIsConnected(77-80)selectOtherAccounts(202-205)selectPin(43-43)selectIsPinCodeOpen(50-53)selectGlobalProps(192-195)selectCurrency(88-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: iOS Build
- GitHub Check: Android Build
🔇 Additional comments (4)
src/redux/selectors/index.ts (3)
1-21: Excellent documentation.The header comments clearly explain the purpose of memoized selectors and provide concrete migration examples. This will help developers understand and adopt the pattern consistently.
236-253: Factory selectors correctly implemented.The factory selector pattern (returning a new selector on each call) is the correct approach for parameterized selections that need separate memoization per component instance. This enables proper memoization while supporting dynamic arguments.
22-272: Comprehensive and well-structured selector implementation.The selector organization is clear (Application, Account, Cache, Posts, Communities, UI sections), and the implementation correctly uses
createSelectorfor memoization. Safe defaults (e.g.,|| [],|| null,|| 0) prevent runtime errors from undefined values.src/screens/application/container/applicationContainer.tsx (1)
929-948: Application and Account state successfully migrated to selectors.The migration to selectors for Application and Account state is complete and correct. All props now derive from centralized, memoized selectors, which improves performance and maintainability.
What does this PR?
Where should the reviewer start?
Steps to reproduce
Issue number
Screenshots/Video
Summary by CodeRabbit
Refactor
Performance
Dependencies
✏️ Tip: You can customize this high-level summary in your review settings.