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

Commit

Permalink
migrate autofill data
Browse files Browse the repository at this point in the history
auditors: @bbondy, @darkdh
  • Loading branch information
bridiver committed Aug 27, 2016
1 parent 9be28c2 commit c46e7ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,23 @@ module.exports.loadAppState = () => {

try {
data = Object.assign(module.exports.defaultAppState(), JSON.parse(data))
// autofill data migration
if (Array.isArray(data.autofill.addresses)) {
let addresses = exports.defaultAppState().autofill.addresses
data.autofill.addresses.forEach((guid) => {
addresses.guid.push(guid)
addresses.timestamp = new Date().getTime()
})
data.autofill.addresses = addresses
}
if (Array.isArray(data.autofill.creditCards)) {
let creditCards = exports.defaultAppState().autofill.creditCards
data.autofill.creditCards.forEach((guid) => {
creditCards.guid.push(guid)
creditCards.timestamp = new Date().getTime()
})
data.autofill.creditCards = creditCards
}
// xml migration
if (data.settings[settings.DEFAULT_SEARCH_ENGINE] === 'content/search/google.xml') {
data.settings[settings.DEFAULT_SEARCH_ENGINE] = 'Google'
Expand Down
8 changes: 4 additions & 4 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ const handleAppAction = (action) => {
Filtering.removeAutofillAddress(action.originalDetail.get('guid').toJS())
}
appState = appState.setIn(['autofill', 'addresses', 'guid'], addresses.push(Immutable.fromJS(guid)))
appState = appState.setIn(['autofill', 'addresses', 'timestamp'], Immutable.fromJS(new Date().getTime()))
appState = appState.setIn(['autofill', 'addresses', 'timestamp'], new Date().getTime())
break
}
case AppConstants.APP_REMOVE_AUTOFILL_ADDRESS:
Expand All @@ -572,7 +572,7 @@ const handleAppAction = (action) => {
return Immutable.is(address, action.detail.get('guid'))
}))
Filtering.removeAutofillAddress(action.detail.get('guid').toJS())
appState = appState.setIn(['autofill', 'addresses', 'timestamp'], Immutable.fromJS(new Date().getTime()))
appState = appState.setIn(['autofill', 'addresses', 'timestamp'], new Date().getTime())
break
}
case AppConstants.APP_ADD_AUTOFILL_CREDIT_CARD:
Expand All @@ -590,7 +590,7 @@ const handleAppAction = (action) => {
Filtering.removeAutofillCreditCard(action.originalDetail.get('guid').toJS())
}
appState = appState.setIn(['autofill', 'creditCards', 'guid'], creditCards.push(Immutable.fromJS(guid)))
appState = appState.setIn(['autofill', 'creditCards', 'timestamp'], Immutable.fromJS(new Date().getTime()))
appState = appState.setIn(['autofill', 'creditCards', 'timestamp'], new Date().getTime())
break
}
case AppConstants.APP_REMOVE_AUTOFILL_CREDIT_CARD:
Expand All @@ -601,7 +601,7 @@ const handleAppAction = (action) => {
return Immutable.is(card, action.detail.get('guid'))
}))
Filtering.removeAutofillCreditCard(action.detail.get('guid').toJS())
appState = appState.setIn(['autofill', 'creditCards', 'timestamp'], Immutable.fromJS(new Date().getTime()))
appState = appState.setIn(['autofill', 'creditCards', 'timestamp'], new Date().getTime())
break
}
default:
Expand Down

2 comments on commit c46e7ec

@bbondy
Copy link
Member

@bbondy bbondy commented on c46e7ec Aug 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@darkdh
Copy link
Member

@darkdh darkdh commented on c46e7ec Aug 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.