Skip to content

Commit

Permalink
refactor: move smartTransactionsMigrationApplied into PreferencesCont…
Browse files Browse the repository at this point in the history
…roller featureFlags

- Move smartTransactionsMigrationApplied from PreferencesController root to featureFlags object
- Aligns with existing pattern of using featureFlags for UI states
- Maintains consistency with smartTransactionsBannerDismissed placement
  • Loading branch information
httpJunkie committed Jan 17, 2025
1 parent d745beb commit d767fe1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/selectors/preferencesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const selectPrivacyMode = createSelector(
export const selectSmartTransactionsMigrationApplied = createSelector(
selectPreferencesControllerState,
(preferencesControllerState: PreferencesState) =>
preferencesControllerState.smartTransactionsMigrationApplied ?? false,
preferencesControllerState.featureFlags?.smartTransactionsMigrationApplied ?? false,
);

export const selectSmartTransactionsBannerDismissed = createSelector(
Expand Down
7 changes: 4 additions & 3 deletions app/store/migrations/096.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface State {
backgroundState: {
PreferencesController: {
smartTransactionsOptInStatus: boolean;
smartTransactionsMigrationApplied: boolean;
featureFlags: {
smartTransactionsMigrationApplied: boolean;
smartTransactionsBannerDismissed: boolean;
};
};
Expand Down Expand Up @@ -77,6 +77,7 @@ export default function migrate(state: unknown) {
if (!preferences.featureFlags) {
preferences.featureFlags = {
smartTransactionsBannerDismissed: false,
smartTransactionsMigrationApplied: false,
};
}

Expand All @@ -90,9 +91,9 @@ export default function migrate(state: unknown) {
(currentOptInStatus === false && !hasExistingSmartTransactions(newState))
) {
preferences.smartTransactionsOptInStatus = true;
preferences.smartTransactionsMigrationApplied = true;
preferences.featureFlags.smartTransactionsMigrationApplied = true;
} else {
preferences.smartTransactionsMigrationApplied = true;
preferences.featureFlags.smartTransactionsMigrationApplied = true;
}

preferences.featureFlags.smartTransactionsBannerDismissed = false;
Expand Down

0 comments on commit d767fe1

Please sign in to comment.