mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove betaUI preference state, replace with completedUiMigration
This commit is contained in:
parent
a7a6318c13
commit
c52ba96b85
@ -33,10 +33,7 @@ class PreferencesController {
|
|||||||
tokens: [],
|
tokens: [],
|
||||||
suggestedTokens: {},
|
suggestedTokens: {},
|
||||||
useBlockie: false,
|
useBlockie: false,
|
||||||
featureFlags: {
|
featureFlags: {},
|
||||||
betaUI: true,
|
|
||||||
skipAnnounceBetaUI: true,
|
|
||||||
},
|
|
||||||
knownMethodData: {},
|
knownMethodData: {},
|
||||||
currentLocale: opts.initLangCode,
|
currentLocale: opts.initLangCode,
|
||||||
identities: {},
|
identities: {},
|
||||||
@ -47,6 +44,7 @@ class PreferencesController {
|
|||||||
useNativeCurrencyAsPrimaryCurrency: true,
|
useNativeCurrencyAsPrimaryCurrency: true,
|
||||||
},
|
},
|
||||||
completedOnboarding: false,
|
completedOnboarding: false,
|
||||||
|
completedUiMigration: false,
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
|
|
||||||
this.diagnostics = opts.diagnostics
|
this.diagnostics = opts.diagnostics
|
||||||
@ -552,6 +550,14 @@ class PreferencesController {
|
|||||||
return Promise.resolve(true)
|
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
|
// PRIVATE METHODS
|
||||||
//
|
//
|
||||||
|
29
app/scripts/migrations/032.js
Normal file
29
app/scripts/migrations/032.js
Normal file
@ -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
|
||||||
|
}
|
@ -502,17 +502,15 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.useBlockie, true)
|
assert.equal(state.useBlockie, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates feature flag', () => {
|
it('updates an arbitrary feature flag', () => {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_FEATURE_FLAGS,
|
type: actions.UPDATE_FEATURE_FLAGS,
|
||||||
value: {
|
value: {
|
||||||
betaUI: true,
|
foo: true,
|
||||||
skipAnnounceBetaUI: true,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.equal(state.featureFlags.betaUI, true)
|
assert.equal(state.featureFlags.foo, true)
|
||||||
assert.equal(state.featureFlags.skipAnnounceBetaUI, true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates network endpoint type', () => {
|
it('updates network endpoint type', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user