Commit 2e4ef85
authored
chore: migrate off of useFeatureFlag (MetaMask#24125)
## **Description**
This PR migrates feature flag checks from the custom `useFeatureFlag`
hook to Redux selectors, aligning with the codebase's feature flag
architecture guidelines.
### Reason for change:
- The existing `useFeatureFlag` hook was creating an inconsistent
pattern for accessing feature flags
- Redux selectors provide better memoization, testability, and
integration with the existing state management architecture
- Centralizes feature flag access patterns for better maintainability
### Solution:
- Added new Redux selectors for OTA Updates, Full Page Account List, and
Rewards feature flags
- Each selector includes both a "raw" version (direct flag value) and a
combined version that respects the `basicFunctionalityEnabled` setting
- Updated all consuming components to use `useSelector` with the new
selectors
- Added comprehensive test coverage for all new selectors
- Removed the deprecated `useFeatureFlag` hook
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
Feature: Feature Flag Selectors
Scenario: OTA Updates flag respects basic functionality setting
Given the app has basic functionality enabled
And the remote feature flag for OTA updates is enabled
When the app checks if OTA updates are enabled
Then the selector returns true
Scenario: Full Page Account List flag is disabled when basic
functionality is off
Given the app has basic functionality disabled
And the remote feature flag for full page account list is enabled
When the AccountSelector component renders
Then it uses the non-full-page account list UI
Scenario: Rewards flags work correctly
Given the app has basic functionality enabled
And the rewards feature flags are enabled remotely
When the WaysToEarn component checks mUSD holding flag
Then the appropriate rewards options are displayed##
**Screenshots/Recordings**
### **Before**
N/A - Internal refactoring with no visual changes
### **After**
N/A - Internal refactoring with no visual changes
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.1 parent 2ca6335 commit 2e4ef85
18 files changed
Lines changed: 713 additions & 252 deletions
File tree
- app
- components
- UI/Rewards/components/Tabs/OverviewTab/WaysToEarn
- Views
- AccountSelector
- FeatureFlagOverride
- hooks
- constants
- selectors/featureFlagController
- fullPageAccountList
- otaUpdates
- rewards
Lines changed: 10 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
90 | 89 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 90 | + | |
97 | 91 | | |
98 | 92 | | |
99 | 93 | | |
| |||
283 | 277 | | |
284 | 278 | | |
285 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
286 | 283 | | |
287 | 284 | | |
288 | 285 | | |
| |||
Lines changed: 2 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
| |||
263 | 260 | | |
264 | 261 | | |
265 | 262 | | |
266 | | - | |
267 | | - | |
268 | | - | |
| 263 | + | |
269 | 264 | | |
270 | 265 | | |
271 | 266 | | |
| |||
Lines changed: 17 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | | - | |
674 | | - | |
675 | 673 | | |
676 | 674 | | |
677 | | - | |
678 | | - | |
679 | | - | |
| 675 | + | |
680 | 676 | | |
681 | 677 | | |
682 | 678 | | |
683 | | - | |
| 679 | + | |
684 | 680 | | |
685 | 681 | | |
686 | 682 | | |
| |||
702 | 698 | | |
703 | 699 | | |
704 | 700 | | |
705 | | - | |
| 701 | + | |
706 | 702 | | |
707 | 703 | | |
708 | 704 | | |
| |||
725 | 721 | | |
726 | 722 | | |
727 | 723 | | |
728 | | - | |
| 724 | + | |
729 | 725 | | |
730 | 726 | | |
731 | 727 | | |
| |||
750 | 746 | | |
751 | 747 | | |
752 | 748 | | |
753 | | - | |
| 749 | + | |
754 | 750 | | |
755 | 751 | | |
756 | 752 | | |
| |||
777 | 773 | | |
778 | 774 | | |
779 | 775 | | |
780 | | - | |
| 776 | + | |
781 | 777 | | |
782 | 778 | | |
783 | 779 | | |
| |||
806 | 802 | | |
807 | 803 | | |
808 | 804 | | |
809 | | - | |
| 805 | + | |
810 | 806 | | |
811 | 807 | | |
812 | 808 | | |
| |||
840 | 836 | | |
841 | 837 | | |
842 | 838 | | |
843 | | - | |
| 839 | + | |
844 | 840 | | |
845 | 841 | | |
846 | 842 | | |
| |||
864 | 860 | | |
865 | 861 | | |
866 | 862 | | |
867 | | - | |
| 863 | + | |
868 | 864 | | |
869 | 865 | | |
870 | 866 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
| 98 | + | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments