aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/controllers/preferences.js14
-rw-r--r--app/scripts/migrations/032.js29
-rw-r--r--test/unit/ui/app/reducers/metamask.spec.js8
3 files changed, 42 insertions, 9 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index d2ef987f2..c0716cc42 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -33,10 +33,7 @@ class PreferencesController {
tokens: [],
suggestedTokens: {},
useBlockie: false,
- featureFlags: {
- betaUI: true,
- skipAnnounceBetaUI: true,
- },
+ featureFlags: {},
knownMethodData: {},
currentLocale: opts.initLangCode,
identities: {},
@@ -47,6 +44,7 @@ class PreferencesController {
useNativeCurrencyAsPrimaryCurrency: true,
},
completedOnboarding: false,
+ completedUiMigration: false,
}, opts.initState)
this.diagnostics = opts.diagnostics
@@ -552,6 +550,14 @@ class PreferencesController {
return Promise.resolve(true)
}
+ /**
+ * Sets the {@code completedUiMigration} state to {@code true}, indicating that the user has completed the UI switch.
+ */
+ completeUiMigration () {
+ this.store.updateState({ completedUiMigration: true })
+ return Promise.resolve(true)
+ }
+
//
// PRIVATE METHODS
//
diff --git a/app/scripts/migrations/032.js b/app/scripts/migrations/032.js
new file mode 100644
index 000000000..e89fe383f
--- /dev/null
+++ b/app/scripts/migrations/032.js
@@ -0,0 +1,29 @@
+const version = 32
+const clone = require('clone')
+
+/**
+ * The purpose of this migration is to set the {@code completedUiMigration} flag based on the user's UI preferences
+ */
+module.exports = {
+ version,
+ migrate: async function (originalVersionedData) {
+ const versionedData = clone(originalVersionedData)
+ versionedData.meta.version = version
+ const state = versionedData.data
+ versionedData.data = transformState(state)
+ return versionedData
+ },
+}
+
+function transformState (state) {
+ const { PreferencesController } = state
+
+ if (PreferencesController) {
+ const { betaUI } = PreferencesController.featureFlags || {}
+ // Users who have been using the "beta" UI are considered to have completed the migration
+ // as they'll see no difference in this version
+ PreferencesController.completedUiMigration = betaUI
+ }
+
+ return state
+}
diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js
index 502e7ef33..8cdb780fe 100644
--- a/test/unit/ui/app/reducers/metamask.spec.js
+++ b/test/unit/ui/app/reducers/metamask.spec.js
@@ -502,17 +502,15 @@ describe('MetaMask Reducers', () => {
assert.equal(state.useBlockie, true)
})
- it('updates feature flag', () => {
+ it('updates an arbitrary feature flag', () => {
const state = reduceMetamask({}, {
type: actions.UPDATE_FEATURE_FLAGS,
value: {
- betaUI: true,
- skipAnnounceBetaUI: true,
+ foo: true,
},
})
- assert.equal(state.featureFlags.betaUI, true)
- assert.equal(state.featureFlags.skipAnnounceBetaUI, true)
+ assert.equal(state.featureFlags.foo, true)
})
it('updates network endpoint type', () => {