Skip to content

Commit

Permalink
use users old timezone selection and update to use constants where ap…
Browse files Browse the repository at this point in the history
…plicable
  • Loading branch information
NikkiWines committed Mar 25, 2021
1 parent 1fa1e20 commit f3cfc16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libs/migrations/ReformatTimezone.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';

// This migration changes the format of the timezone in the Onyx key MY_PERSONAL_DETAILS from a string to an object
export default function () {
Expand All @@ -10,7 +9,7 @@ export default function () {
// then update the timezone to be the default timezone and set the myPersonalDetails
// key with the updated values
const connectionID = Onyx.connect({
key: 'myPersonalDetails',
key: ONYXKEYS.MY_PERSONAL_DETAILS,
callback: (myPersonalDetails) => {
Onyx.disconnect(connectionID);

Expand All @@ -25,9 +24,10 @@ export default function () {
return resolve();
}

// Replace the old timezone with the default timezone
// Update the timezone with the user's old timezone selection and set "automatic" to false
// because we don't know if their old timezone was set automatically or not
const details = myPersonalDetails;
details.timezone = CONST.DEFAULT_TIME_ZONE;
details.timezone = {selected: details.timezone, automatic: false};
Onyx.set({
[ONYXKEYS.MY_PERSONAL_DETAILS]: details,
})
Expand Down

0 comments on commit f3cfc16

Please sign in to comment.