Skip to content

Commit

Permalink
chore: add remote config variables for dapps explorer search and filt…
Browse files Browse the repository at this point in the history
…er (#3460)

### Description

Adds the remote config variables `dappsFilterEnabled` and
`dappsSearchEnabled`.

### Test plan
 
Tested locally with unit tests and in CI.

### Related issues

- RET-581

### Backwards compatibility

Yes
  • Loading branch information
MuckT authored Feb 23, 2023
1 parent 109bc32 commit 621ddd2
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export interface RemoteConfigValues {
guaranteedSwapPriceEnabled: boolean
superchargeV2Enabled: boolean
superchargeRewardContractAddress: string
dappsFilterEnabled: boolean
dappsSearchEnabled: boolean
}

export function* appRemoteFeatureFlagSaga() {
Expand Down
4 changes: 4 additions & 0 deletions src/dapps/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ export const favoriteDappsSelector = createSelector(
return favoriteDapps
}
)

export const dappsFilterEnabledSelector = (state: RootState) => state.dapps.dappsFilterEnabled

export const dappsSearchEnabledSelector = (state: RootState) => state.dapps.dappsSearchEnabled
4 changes: 4 additions & 0 deletions src/dapps/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface State {
dappFavoritesEnabled: boolean
favoriteDappIds: string[]
dappsMinimalDisclaimerEnabled: boolean
dappsFilterEnabled: boolean
dappsSearchEnabled: boolean
}

const initialState: State = {
Expand All @@ -34,6 +36,8 @@ const initialState: State = {
dappFavoritesEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.dappFavoritesEnabled,
favoriteDappIds: [],
dappsMinimalDisclaimerEnabled: false,
dappsFilterEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.dappsFilterEnabled,
dappsSearchEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.dappsSearchEnabled,
}

export interface DappSelectedAction {
Expand Down
2 changes: 2 additions & 0 deletions src/firebase/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ export async function fetchRemoteConfigValues(): Promise<RemoteConfigValues | nu
guaranteedSwapPriceEnabled: flags.guaranteedSwapPriceEnabled.asBoolean(),
superchargeV2Enabled: flags.superchargeV2Enabled.asBoolean(),
superchargeRewardContractAddress: flags.superchargeRewardContractAddress.asString(),
dappsFilterEnabled: flags.dappsFilterEnabled.asBoolean(),
dappsSearchEnabled: flags.dappsSearchEnabled.asBoolean(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/firebase/remoteConfigValuesDefaults.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
guaranteedSwapPriceEnabled: false,
superchargeV2Enabled: false,
superchargeRewardContractAddress: '',
dappsFilterEnabled: false,
dappsSearchEnabled: false,
}
2 changes: 2 additions & 0 deletions src/firebase/remoteConfigValuesDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
guaranteedSwapPriceEnabled: false,
superchargeV2Enabled: false,
superchargeRewardContractAddress: '',
dappsFilterEnabled: false,
dappsSearchEnabled: false,
}
8 changes: 8 additions & 0 deletions src/redux/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,4 +1046,12 @@ export const migrations = {
},
}),
111: (state: any) => state,
112: (state: any) => ({
...state,
dapps: {
...state.dapps,
dappsFilterEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.dappsFilterEnabled,
dappsSearchEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.dappsSearchEnabled,
},
}),
}
4 changes: 3 additions & 1 deletion src/redux/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('store state', () => {
Object {
"_persist": Object {
"rehydrated": true,
"version": 111,
"version": 112,
},
"account": Object {
"acceptedTerms": false,
Expand Down Expand Up @@ -185,10 +185,12 @@ describe('store state', () => {
"dappFavoritesEnabled": false,
"dappListApiUrl": null,
"dappsCategories": Array [],
"dappsFilterEnabled": false,
"dappsList": Array [],
"dappsListError": null,
"dappsListLoading": false,
"dappsMinimalDisclaimerEnabled": false,
"dappsSearchEnabled": false,
"dappsWebViewEnabled": false,
"favoriteDappIds": Array [],
"maxNumRecentDapps": 0,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const persistConfig: PersistConfig<RootState> = {
key: 'root',
// default is -1, increment as we make migrations
// See https://github.com/valora-inc/wallet/tree/main/WALLET.md#redux-state-migration
version: 111,
version: 112,
keyPrefix: `reduxStore-`, // the redux-persist default is `persist:` which doesn't work with some file systems.
storage: FSStorage(),
blacklist: ['networkInfo', 'alert', 'imports', 'supercharge', 'swap'],
Expand Down
8 changes: 8 additions & 0 deletions test/RootStateSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,9 @@
},
"type": "array"
},
"dappsFilterEnabled": {
"type": "boolean"
},
"dappsList": {
"items": {
"$ref": "#/definitions/Dapp"
Expand All @@ -3194,6 +3197,9 @@
"dappsMinimalDisclaimerEnabled": {
"type": "boolean"
},
"dappsSearchEnabled": {
"type": "boolean"
},
"dappsWebViewEnabled": {
"type": "boolean"
},
Expand All @@ -3219,10 +3225,12 @@
"dappFavoritesEnabled",
"dappListApiUrl",
"dappsCategories",
"dappsFilterEnabled",
"dappsList",
"dappsListError",
"dappsListLoading",
"dappsMinimalDisclaimerEnabled",
"dappsSearchEnabled",
"dappsWebViewEnabled",
"favoriteDappIds",
"maxNumRecentDapps",
Expand Down
15 changes: 14 additions & 1 deletion test/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,19 @@ export const v111Schema = {
},
}

export const v112Schema = {
...v111Schema,
_persist: {
...v111Schema._persist,
version: 112,
},
dapps: {
...v111Schema.dapps,
dappsFilterEnabled: false,
dappsSearchEnabled: false,
},
}

export function getLatestSchema(): Partial<RootState> {
return v111Schema as Partial<RootState>
return v112Schema as Partial<RootState>
}

0 comments on commit 621ddd2

Please sign in to comment.