Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

add support for legacy ledger settings #10441

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,37 @@ module.exports.runPreMigrations = (data) => {
data.autofill.creditCards.guid = guids
}
}
// xml migration
if (data.settings) {
// xml migration
if (data.settings[settings.DEFAULT_SEARCH_ENGINE] === 'content/search/google.xml') {
data.settings[settings.DEFAULT_SEARCH_ENGINE] = 'Google'
}
if (data.settings[settings.DEFAULT_SEARCH_ENGINE] === 'content/search/duckduckgo.xml') {
data.settings[settings.DEFAULT_SEARCH_ENGINE] = 'DuckDuckGo'
}
// ledger payments migration. see PR #10164
// changes was introduced in 0.21.x.
// if legacy setting exist, make sure the new setting inherits the legacy value
if (data.settings[settings.AUTO_SUGGEST_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_AUTO_SUGGEST] = data.settings[settings.AUTO_SUGGEST_SITES]
}
if (data.settings[settings.MINIMUM_VISIT_TIME] != null) {
data.settings[settings.PAYMENTS_MINIMUM_VISIT_TIME] = data.settings[settings.MINIMUM_VISIT_TIME]
}
if (data.settings[settings.MINIMUM_VISITS] != null) {
data.settings[settings.PAYMENTS_MINIMUM_VISITS] = data.settings[settings.MINIMUM_VISITS]
}
if (data.settings[settings.HIDE_LOWER_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_SHOW_LESS] = data.settings[settings.HIDE_LOWER_SITES]
}
if (data.settings[settings.HIDE_EXCLUDED_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_HIDE_EXCLUDED] = data.settings[settings.HIDE_EXCLUDED_SITES]
}
// PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED kept the same
// constant but has its value changed.
if (data.settings['payments.notificationTryPaymentsDismissed'] != null) {
data.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED] = data.settings['payments.notificationTryPaymentsDismissed']
}
}

if (data.sites) {
Expand Down
12 changes: 11 additions & 1 deletion js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,17 @@ module.exports = {
'general.bookmarks-toolbar-mode': null,
'general.is-default-browser': null,
'notification-add-funds-timestamp': null,
'notification-reconcile-soon-timestamp': null
'notification-reconcile-soon-timestamp': null,
// ---> payments -- payments-deprecated
// DO NOT CHANGE THESE VALUES
// these are handled by sessionStore and replaced with their new values.
// They're not used anywhere else other than unit tests.
'advanced.hide-excluded-sites': false,
'advanced.minimum-visit-time': 8000,
'advanced.minimum-visits': 1,
'advanced.auto-suggest-sites': true,
'advanced.hide-lower-sites': true
// ---> end payments-deprecated
},
defaultFavicon: 'img/empty_favicon.png'
}
8 changes: 7 additions & 1 deletion js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ const settings = {
VIMIUM_ENABLED: 'extensions.vimium.enabled',
HONEY_ENABLED: 'extensions.honey.enabled',
PINTEREST_ENABLED: 'extensions.pinterest.enabled',
METAMASK_ENABLED: 'extensions.metamask.enabled'
METAMASK_ENABLED: 'extensions.metamask.enabled',
// > phased out with 0.21.0
HIDE_EXCLUDED_SITES: 'advanced.hide-excluded-sites',
HIDE_LOWER_SITES: 'advanced.hide-lower-sites',
MINIMUM_VISIT_TIME: 'advanced.minimum-visit-time',
MINIMUM_VISITS: 'advanced.minimum-visits',
AUTO_SUGGEST_SITES: 'advanced.auto-suggest-sites'
}

module.exports = settings
52 changes: 52 additions & 0 deletions test/unit/app/sessionStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,56 @@ describe('sessionStore unit tests', function () {
}
})
})

describe('runPreMigrations', function () {
let data = {
settings: {
[settings.AUTO_SUGGEST_SITES]: 'sure thing',
[settings.MINIMUM_VISIT_TIME]: 'almost instantly',
[settings.MINIMUM_VISITS]: 'a million',
[settings.HIDE_LOWER_SITES]: 'pls do it',
[settings.HIDE_EXCLUDED_SITES]: 'no thanks',
'payments.notificationTryPaymentsDismissed': 'why would I?'
}
}

describe('if data.settings exist', function () {
it('PAYMENTS_SITES_AUTO_SUGGEST inherits data from AUTO_SUGGEST_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_AUTO_SUGGEST]
const oldValue = runPreMigrations.settings[settings.AUTO_SUGGEST_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_MINIMUM_VISIT_TIME inherits data from MINIMUM_VISIT_TIME', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_MINIMUM_VISIT_TIME]
const oldValue = runPreMigrations.settings[settings.MINIMUM_VISIT_TIME]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_MINIMUM_VISITS inherits data from MINIMUM_VISITS', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_MINIMUM_VISITS]
const oldValue = runPreMigrations.settings[settings.MINIMUM_VISITS]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_SITES_SHOW_LESS inherits data from HIDE_LOWER_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_SHOW_LESS]
const oldValue = runPreMigrations.settings[settings.HIDE_LOWER_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_SITES_HIDE_EXCLUDED inherits data from HIDE_EXCLUDED_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_HIDE_EXCLUDED]
const oldValue = runPreMigrations.settings[settings.HIDE_EXCLUDED_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED inherits data from payments.notificationTryPaymentsDismissed', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED]
const oldValue = runPreMigrations.settings['payments.notificationTryPaymentsDismissed']
assert.equal(newValue, oldValue)
})
})
})
})