diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js
index 9037d28125ce..883047058594 100644
--- a/src/ONYXKEYS.js
+++ b/src/ONYXKEYS.js
@@ -35,9 +35,6 @@ export default {
// Contains all the personalDetails the user has access to
PERSONAL_DETAILS: 'personalDetails',
- // Contains the user preference for the LHN priority mode
- PRIORITY_MODE: 'priorityMode',
-
// Indicates whether an update is available and ready to beinstalled.
UPDATE_AVAILABLE: 'updateAvailable',
@@ -53,8 +50,12 @@ export default {
BETAS: 'betas',
// NVP keys
+ // Contains the user's payPalMe address
NVP_PAYPAL_ME_ADDRESS: 'nvp_paypalMeAddress',
+ // Contains the user preference for the LHN priority mode
+ NVP_PRIORITY_MODE: 'nvp_priorityMode',
+
// Collection Keys
COLLECTION: {
REPORT: 'report_',
diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js
index 397345801370..d89e0375b422 100644
--- a/src/libs/Navigation/AppNavigator/AuthScreens.js
+++ b/src/libs/Navigation/AppNavigator/AuthScreens.js
@@ -23,7 +23,7 @@ import CONFIG from '../../../CONFIG';
import {fetchCountryCodeByRequestIP} from '../../actions/GeoLocation';
import KeyboardShortcut from '../../KeyboardShortcut';
import Navigation from '../Navigation';
-import {getBetas} from '../../actions/User';
+import * as User from '../../actions/User';
import NameValuePair from '../../actions/NameValuePair';
// Main drawer navigator
@@ -69,10 +69,10 @@ class AuthScreens extends React.Component {
}).then(subscribeToReportCommentEvents);
// Fetch some data we need on initialization
- NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.PRIORITY_MODE, 'default');
+ NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.NVP_PRIORITY_MODE, 'default');
PersonalDetails.fetch();
- PersonalDetails.fetchTimezone();
- getBetas();
+ User.fetch();
+ User.getBetas();
fetchAllReports(true, true);
fetchCountryCodeByRequestIP();
UnreadIndicatorUpdater.listenForReportChanges();
@@ -85,8 +85,8 @@ class AuthScreens extends React.Component {
return;
}
PersonalDetails.fetch();
- PersonalDetails.fetchTimezone();
- getBetas();
+ User.fetch();
+ User.getBetas();
}, 1000 * 60 * 30);
Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER);
diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js
index 292873979bdf..4faccd19f686 100644
--- a/src/libs/actions/PersonalDetails.js
+++ b/src/libs/actions/PersonalDetails.js
@@ -88,6 +88,7 @@ function formatPersonalDetails(personalDetailsList) {
const avatar = getAvatar(personalDetailsResponse, login);
const displayName = getDisplayName(login, personalDetailsResponse);
const pronouns = lodashGet(personalDetailsResponse, 'pronouns', '');
+ const timezone = lodashGet(personalDetailsResponse, 'timeZone', CONST.DEFAULT_TIME_ZONE);
return {
...finalObject,
@@ -96,26 +97,12 @@ function formatPersonalDetails(personalDetailsList) {
avatar,
displayName,
pronouns,
+ timezone,
},
};
}, {});
}
-/**
- * Get the timezone of the logged in user
- */
-function fetchTimezone() {
- API.Get({
- returnValueList: 'nameValuePairs',
- name: 'timeZone',
- })
- .then((response) => {
- const timezone = lodashGet(response.nameValuePairs, [CONST.NVP.TIMEZONE], CONST.DEFAULT_TIME_ZONE);
- Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, {timezone});
- })
- .catch(error => console.debug('Error fetching user timezone', error));
-}
-
/**
* Get the personal details for our organization
*/
@@ -240,7 +227,6 @@ NetworkConnection.onReconnect(fetch);
export {
fetch,
- fetchTimezone,
getFromReportParticipants,
getDisplayName,
getDefaultAvatar,
diff --git a/src/libs/migrateOnyx.js b/src/libs/migrateOnyx.js
index a93c50bb6455..8b0d428076c2 100644
--- a/src/libs/migrateOnyx.js
+++ b/src/libs/migrateOnyx.js
@@ -1,4 +1,5 @@
import RenameActiveClientsKey from './migrations/RenameActiveClientsKey';
+import RenamePriorityModeKey from './migrations/RenamePriorityModeKey';
export default function () {
const startTime = Date.now();
@@ -8,6 +9,7 @@ export default function () {
// Add all migrations to an array so they are executed in order
const migrationPromises = [
RenameActiveClientsKey,
+ RenamePriorityModeKey,
];
// Reduce all promises down to a single promise. All promises run in a linear fashion, waiting for the
diff --git a/src/libs/migrations/RenamePriorityModeKey.js b/src/libs/migrations/RenamePriorityModeKey.js
new file mode 100644
index 000000000000..c80c1058bbae
--- /dev/null
+++ b/src/libs/migrations/RenamePriorityModeKey.js
@@ -0,0 +1,33 @@
+import Onyx from 'react-native-onyx';
+import _ from 'underscore';
+import ONYXKEYS from '../../ONYXKEYS';
+
+// This migration changes the name of the Onyx key NVP_PRIORITY_MODE from priorityMode to nvp_priorityMode
+export default function () {
+ return new Promise((resolve) => {
+ // Connect to the old key in Onyx to get the old value of priorityMode
+ // then set the new key nvp_priorityMode to hold the old data
+ // finally remove the old key by setting the value to null
+ const connectionID = Onyx.connect({
+ key: 'priorityMode',
+ callback: (oldPriorityMode) => {
+ Onyx.disconnect(connectionID);
+
+ // Fail early here because there is nothing to migrate
+ if (_.isEmpty(oldPriorityMode)) {
+ console.debug('[Migrate Onyx] Skipped migration RenamePriorityModeKey');
+ return resolve();
+ }
+
+ Onyx.multiSet({
+ priorityMode: null,
+ [ONYXKEYS.NVP_PRIORITY_MODE]: oldPriorityMode,
+ })
+ .then(() => {
+ console.debug('[Migrate Onyx] Ran migration RenamePriorityModeKey');
+ resolve();
+ });
+ },
+ });
+ });
+}
diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js
index d4b4be1c0712..a63ba1a6b924 100644
--- a/src/pages/ProfilePage.js
+++ b/src/pages/ProfilePage.js
@@ -108,6 +108,8 @@ const ProfilePage = ({personalDetails, route}) => {
{moment().tz(profileDetails.timezone.selected).format('LT')}
+ {' '}
+ {moment().tz(profileDetails.timezone.selected).zoneAbbr()}
) : null}
diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js
index 8304509eb351..4716530e07b6 100644
--- a/src/pages/home/HeaderView.js
+++ b/src/pages/home/HeaderView.js
@@ -83,17 +83,18 @@ const HeaderView = (props) => {
Navigation.navigate(ROUTES.getProfileRoute(participants[0]));
}
}}
+ style={[styles.flexRow, styles.alignItemsCenter]}
>
+
+
+
-
-
-
togglePinnedState(props.report)}
diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js
index 2f64b227b13e..0a9a0d9fdac3 100644
--- a/src/pages/home/sidebar/SidebarLinks.js
+++ b/src/pages/home/sidebar/SidebarLinks.js
@@ -179,7 +179,7 @@ export default compose(
key: ONYXKEYS.CURRENTLY_VIEWED_REPORTID,
},
priorityMode: {
- key: ONYXKEYS.PRIORITY_MODE,
+ key: ONYXKEYS.NVP_PRIORITY_MODE,
},
}),
)(SidebarLinks);
diff --git a/src/pages/settings/PreferencesPage.js b/src/pages/settings/PreferencesPage.js
index b964cb75dceb..f3da3c89fa83 100644
--- a/src/pages/settings/PreferencesPage.js
+++ b/src/pages/settings/PreferencesPage.js
@@ -56,7 +56,7 @@ const PreferencesPage = ({priorityMode}) => (
{/* placeholder from appearing as a selection option. */}
NameValuePair.set(CONST.NVP.PRIORITY_MODE, mode, ONYXKEYS.PRIORITY_MODE)
+ mode => NameValuePair.set(CONST.NVP.PRIORITY_MODE, mode, ONYXKEYS.NVP_PRIORITY_MODE)
}
items={Object.values(priorityModes)}
style={styles.picker}
@@ -80,6 +80,6 @@ PreferencesPage.displayName = 'PreferencesPage';
export default withOnyx({
priorityMode: {
- key: ONYXKEYS.PRIORITY_MODE,
+ key: ONYXKEYS.NVP_PRIORITY_MODE,
},
})(PreferencesPage);
diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js
index 7c1ecf410b7d..42a07b2bf747 100644
--- a/tests/utils/TestHelper.js
+++ b/tests/utils/TestHelper.js
@@ -71,10 +71,7 @@ function fetchPersonalDetailsForTestUser(accountID, email, personalDetailsList)
accountID,
email,
personalDetailsList,
- }))
-
- // fetchTimezone
- .mockImplementationOnce(() => Promise.resolve({}));
+ }));
fetchPersonalDetails();
return waitForPromisesToResolve();