From f1d29bc161a7bc0028901c3eb84d74bcc7a1d101 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Wed, 10 Mar 2021 16:15:42 -0800 Subject: [PATCH 01/12] update myPersonalDetails and personalDetails onyx keys to get timezone from personalDetailsList not separate API call --- src/libs/actions/PersonalDetails.js | 22 ++++------------------ src/libs/actions/User.js | 2 +- src/pages/ProfilePage.js | 2 +- src/pages/home/HomePage.js | 10 +++++----- tests/utils/TestHelper.js | 3 --- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index 292873979bd..beb232c1d26 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 */ @@ -125,7 +112,7 @@ function fetch() { }) .then((data) => { const allPersonalDetails = formatPersonalDetails(data.personalDetailsList); - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails); + Onyx.set(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails); const myPersonalDetails = allPersonalDetails[currentUserEmail] || {avatar: getAvatar(undefined, currentUserEmail)}; @@ -135,7 +122,7 @@ function fetch() { myPersonalDetails.lastName = lodashGet(data.personalDetailsList, [currentUserEmail, 'lastName'], ''); // Set my personal details so they can be easily accessed and subscribed to on their own key - Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails); + Onyx.set(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails); }) .catch(error => console.debug('Error fetching personal details', error)); } @@ -240,7 +227,6 @@ NetworkConnection.onReconnect(fetch); export { fetch, - fetchTimezone, getFromReportParticipants, getDisplayName, getDefaultAvatar, diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 1fba0d94f5c..d994224563a 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -90,7 +90,7 @@ function setSecondaryLogin(login, password) { }); } -export { +export default { changePassword, getBetas, fetch, diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 15bb7ec9f82..ff7e6cfa3ad 100644 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -111,7 +111,7 @@ const ProfilePage = ({personalDetails, match}) => { Local Time - {moment().tz(profileDetails.timezone.selected).format('LT')} + {moment().tz(profileDetails.timezone.selected).format('LT')} {moment().tz(profileDetails.timezone.selected).zoneAbbr()} ) : null} diff --git a/src/pages/home/HomePage.js b/src/pages/home/HomePage.js index 83094b09275..12829b42274 100644 --- a/src/pages/home/HomePage.js +++ b/src/pages/home/HomePage.js @@ -31,7 +31,7 @@ import KeyboardShortcut from '../../libs/KeyboardShortcut'; import {redirect} from '../../libs/actions/App'; import RightDockedModal from '../../components/RightDockedModal'; import IOUModal from '../iou/IOUModal'; -import {getBetas} from '../../libs/actions/User'; +import User from '../../libs/actions/User'; import NameValuePair from '../../libs/actions/NameValuePair'; const propTypes = { @@ -62,8 +62,8 @@ class HomePage extends PureComponent { // Fetch some data we need on initialization NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.PRIORITY_MODE, 'default'); PersonalDetails.fetch(); - PersonalDetails.fetchTimezone(); - getBetas(); + User.fetch(); + User.getBetas(); fetchAllReports(true, true); fetchCountryCodeByRequestIP(); UnreadIndicatorUpdater.listenForReportChanges(); @@ -76,8 +76,8 @@ class HomePage extends PureComponent { return; } PersonalDetails.fetch(); - PersonalDetails.fetchTimezone(); - getBetas(); + User.fetch(); + User.getBetas(); }, 1000 * 60 * 30); Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER); diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js index 10563e916aa..bd36ad8f335 100644 --- a/tests/utils/TestHelper.js +++ b/tests/utils/TestHelper.js @@ -74,9 +74,6 @@ function fetchPersonalDetailsForTestUser(accountID, email, personalDetailsList) personalDetailsList, })) - // fetchTimezone - .mockImplementationOnce(() => Promise.resolve({})); - fetchPersonalDetails(); return waitForPromisesToResolve(); } From 4d81cff7c7dc44f451aaadf8a04e12ec48abf14d Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Wed, 10 Mar 2021 18:01:51 -0800 Subject: [PATCH 02/12] style --- src/pages/ProfilePage.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index ff7e6cfa3ad..4558f8a64d6 100644 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -111,7 +111,9 @@ const ProfilePage = ({personalDetails, match}) => { Local Time - {moment().tz(profileDetails.timezone.selected).format('LT')} {moment().tz(profileDetails.timezone.selected).zoneAbbr()} + {moment().tz(profileDetails.timezone.selected).format('LT')} + {' '} + {moment().tz(profileDetails.timezone.selected).zoneAbbr()} ) : null} From d027da0922a37e16f9378f61c743ae95319eeaa6 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Wed, 17 Mar 2021 12:48:04 -0700 Subject: [PATCH 03/12] merge master, update AuthScreens.js to not call fetchTimeZone() --- src/libs/Navigation/AppNavigator/AuthScreens.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 39734580137..47c21cfe293 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 @@ -71,8 +71,8 @@ class AuthScreens extends React.Component { // Fetch some data we need on initialization NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.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); From d1daae6ab78f4be5565ccd36d3feb7010f200478 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Wed, 17 Mar 2021 12:49:03 -0700 Subject: [PATCH 04/12] undo change to User.js --- src/libs/actions/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index d994224563a..1fba0d94f5c 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -90,7 +90,7 @@ function setSecondaryLogin(login, password) { }); } -export default { +export { changePassword, getBetas, fetch, From f990e66be58c2b2994870d784b809ab48325230b Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Wed, 17 Mar 2021 12:52:32 -0700 Subject: [PATCH 05/12] add semicolons --- src/libs/Navigation/AppNavigator/AuthScreens.js | 4 ++-- tests/utils/TestHelper.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 47c21cfe293..576b610f2bd 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -71,7 +71,7 @@ class AuthScreens extends React.Component { // Fetch some data we need on initialization NameValuePair.get(CONST.NVP.PRIORITY_MODE, ONYXKEYS.PRIORITY_MODE, 'default'); PersonalDetails.fetch(); - User.fetch() + User.fetch(); User.getBetas(); fetchAllReports(true, true); fetchCountryCodeByRequestIP(); @@ -85,7 +85,7 @@ class AuthScreens extends React.Component { return; } PersonalDetails.fetch(); - User.fetch() + User.fetch(); User.getBetas(); }, 1000 * 60 * 30); diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js index b282fd5c062..42a07b2bf74 100644 --- a/tests/utils/TestHelper.js +++ b/tests/utils/TestHelper.js @@ -71,7 +71,7 @@ function fetchPersonalDetailsForTestUser(accountID, email, personalDetailsList) accountID, email, personalDetailsList, - })) + })); fetchPersonalDetails(); return waitForPromisesToResolve(); From 9e34aada4aafdb907a88ef74771313485e5dd3e2 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Thu, 18 Mar 2021 17:48:30 -0700 Subject: [PATCH 06/12] update profilePage to detailsPage update priorityMode nvp to have correct const --- src/ONYXKEYS.js | 7 +++--- src/ROUTES.js | 6 ++--- .../Navigation/AppNavigator/AuthScreens.js | 6 ++--- .../AppNavigator/ModalStackNavigators.js | 22 +++++++++---------- .../AppNavigator/ModalStacks/index.js | 4 ++-- .../AppNavigator/ModalStacks/index.native.js | 4 ++-- src/libs/Navigation/linkingConfig.js | 6 ++--- src/pages/{ProfilePage.js => DetailsPage.js} | 18 +++++++-------- src/pages/home/HeaderView.js | 2 +- src/pages/home/sidebar/SidebarLinks.js | 2 +- src/pages/settings/PreferencesPage.js | 4 ++-- src/styles/styles.js | 6 ++--- 12 files changed, 44 insertions(+), 43 deletions(-) rename src/pages/{ProfilePage.js => DetailsPage.js} (93%) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 8edd302fb8c..488c20dce7d 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/ROUTES.js b/src/ROUTES.js index 5f4c4337c95..0fe51bf894f 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -18,7 +18,7 @@ export default { SEARCH: 'search', SIGNIN: 'signin', SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:validateCode', - PROFILE: 'profile', - PROFILE_WITH_LOGIN: 'profile/:login', - getProfileRoute: login => `profile/${login}`, + DETAILS: 'details', + DETAILS_WITH_LOGIN: 'details/:login', + getDetailsRoute: login => `details/${login}`, }; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 576b610f2bd..769001e6bf5 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -33,7 +33,7 @@ import MainDrawerNavigator from './MainDrawerNavigator'; import { IOUBillStackNavigator, IOURequestModalStackNavigator, - ProfileModalStackNavigator, + DetailsModalStackNavigator, SearchModalStackNavigator, NewGroupModalStackNavigator, NewChatModalStackNavigator, @@ -158,9 +158,9 @@ class AuthScreens extends React.Component { component={SearchModalStackNavigator} /> ( ); -const ProfileModalStackNavigator = () => ( - ( + - - + ); const SearchModalStackNavigator = () => ( @@ -168,7 +168,7 @@ const SettingsModalStackNavigator = () => ( export { IOUBillStackNavigator, IOURequestModalStackNavigator, - ProfileModalStackNavigator, + DetailsModalStackNavigator, SearchModalStackNavigator, NewGroupModalStackNavigator, NewChatModalStackNavigator, diff --git a/src/libs/Navigation/AppNavigator/ModalStacks/index.js b/src/libs/Navigation/AppNavigator/ModalStacks/index.js index ed7c42f8a51..89a8cf1ee59 100644 --- a/src/libs/Navigation/AppNavigator/ModalStacks/index.js +++ b/src/libs/Navigation/AppNavigator/ModalStacks/index.js @@ -5,7 +5,7 @@ const SettingsModalStack = createCustomModalStackNavigator(); const NewChatModalStack = createCustomModalStackNavigator(); const NewGroupModalStack = createCustomModalStackNavigator(); const SearchModalStack = createCustomModalStackNavigator(); -const ProfileModalStack = createCustomModalStackNavigator(); +const DetailsModalStack = createCustomModalStackNavigator(); const IOURequestModalStack = createCustomModalStackNavigator(); const IOUBillModalStack = createCustomModalStackNavigator(); @@ -14,7 +14,7 @@ export { NewChatModalStack, NewGroupModalStack, SearchModalStack, - ProfileModalStack, + DetailsModalStack, IOURequestModalStack, IOUBillModalStack, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js b/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js index 03f5e8edf31..3b26a3efcb4 100644 --- a/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js +++ b/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js @@ -11,7 +11,7 @@ const SettingsModalStack = shouldUseCustomModalStack ? createCustomModalStackNav const NewChatModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const NewGroupModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const SearchModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); -const ProfileModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); +const DetailsModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const IOURequestModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const IOUBillModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); @@ -20,7 +20,7 @@ export { NewChatModalStack, NewGroupModalStack, SearchModalStack, - ProfileModalStack, + DetailsModalStack, IOURequestModalStack, IOUBillModalStack, }; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index a7ad1099204..7424877aa59 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -64,10 +64,10 @@ export default { Search_Root: '', }, }, - Profile: { - initialRouteName: 'Profile_Root', + Details: { + initialRouteName: 'Details_Root', screens: { - Profile_Root: ROUTES.PROFILE_WITH_LOGIN, + Details_Root: ROUTES.DETAILS_WITH_LOGIN, }, }, IOU_Request: { diff --git a/src/pages/ProfilePage.js b/src/pages/DetailsPage.js similarity index 93% rename from src/pages/ProfilePage.js rename to src/pages/DetailsPage.js index a63ba1a6b92..68322d63e5d 100644 --- a/src/pages/ProfilePage.js +++ b/src/pages/DetailsPage.js @@ -35,7 +35,7 @@ const personalDetailsType = PropTypes.shape({ const matchType = PropTypes.shape({ params: PropTypes.shape({ - // login passed via route /profile/:login + // login passed via route /details/:login login: PropTypes.string, }), }); @@ -49,7 +49,7 @@ const propTypes = { route: matchType.isRequired, }; -const ProfilePage = ({personalDetails, route}) => { +const DetailsPage = ({personalDetails, route}) => { const profileDetails = personalDetails[route.params.login]; return ( @@ -60,7 +60,7 @@ const ProfilePage = ({personalDetails, route}) => { {profileDetails ? ( @@ -80,7 +80,7 @@ const ProfilePage = ({personalDetails, route}) => { : null} {profileDetails.login ? ( - + {Str.isSMSLogin(profileDetails.login) ? 'Phone Number' : 'Email'} @@ -92,7 +92,7 @@ const ProfilePage = ({personalDetails, route}) => { ) : null} {profileDetails.pronouns ? ( - + Preferred Pronouns @@ -102,7 +102,7 @@ const ProfilePage = ({personalDetails, route}) => { ) : null} {profileDetails.timezone ? ( - + Local Time @@ -121,11 +121,11 @@ const ProfilePage = ({personalDetails, route}) => { ); }; -ProfilePage.propTypes = propTypes; -ProfilePage.displayName = 'ProfilePage'; +DetailsPage.propTypes = propTypes; +DetailsPage.displayName = 'DetailsPage'; export default withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, }, -})(ProfilePage); +})(DetailsPage); diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index bd2a0fcf4fa..e65210b50b8 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -63,7 +63,7 @@ const HeaderView = props => ( onPress={() => { const {participants} = props.report; if (participants.length === 1) { - Navigation.navigate(ROUTES.getProfileRoute(participants[0])); + Navigation.navigate(ROUTES.getDetailsRoute(participants[0])); } }} > diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index c4215b28e65..3390f1896c9 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -181,7 +181,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 b964cb75dce..f3da3c89fa8 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/src/styles/styles.js b/src/styles/styles.js index 28e0130bc50..cfd6ce1cb7b 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1085,17 +1085,17 @@ const styles = { opacity: 0, }, - profilePageContainer: { + detailsPageContainer: { justifyContent: 'space-between', width: '100%', flex: 1, }, - profilePageSectionContainer: { + detailsPageSectionContainer: { alignSelf: 'flex-start', }, - profilePageSectionVersion: { + detailsPageSectionVersion: { alignSelf: 'center', color: themeColors.textSupporting, fontSize: variables.fontSizeSmall, From 4ce6b365cc576e857d70685dbc1c711bc9e6e080 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Thu, 18 Mar 2021 18:01:35 -0700 Subject: [PATCH 07/12] make both avatar and name selectable --- src/pages/home/HeaderView.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index e65210b50b8..5dfbb33fb5a 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -67,9 +67,11 @@ const HeaderView = props => ( } }} > - + + +
+ -
togglePinnedState(props.report)} From dd91b65105bdc88cb4b6e1a2a03d1db805e5fb92 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Fri, 19 Mar 2021 10:22:28 -0700 Subject: [PATCH 08/12] undo file rename --- src/ONYXKEYS.js | 7 +++--- src/ROUTES.js | 6 ++--- .../Navigation/AppNavigator/AuthScreens.js | 6 ++--- .../AppNavigator/ModalStackNavigators.js | 22 +++++++++---------- .../AppNavigator/ModalStacks/index.js | 4 ++-- .../AppNavigator/ModalStacks/index.native.js | 4 ++-- src/libs/Navigation/linkingConfig.js | 6 ++--- src/pages/{DetailsPage.js => ProfilePage.js} | 18 +++++++-------- src/pages/home/HeaderView.js | 9 ++++---- src/pages/home/sidebar/SidebarLinks.js | 2 +- src/pages/settings/PreferencesPage.js | 4 ++-- src/styles/styles.js | 6 ++--- 12 files changed, 46 insertions(+), 48 deletions(-) rename src/pages/{DetailsPage.js => ProfilePage.js} (93%) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 488c20dce7d..8edd302fb8c 100644 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -35,6 +35,9 @@ 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', @@ -50,12 +53,8 @@ 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/ROUTES.js b/src/ROUTES.js index 0fe51bf894f..5f4c4337c95 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -18,7 +18,7 @@ export default { SEARCH: 'search', SIGNIN: 'signin', SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:validateCode', - DETAILS: 'details', - DETAILS_WITH_LOGIN: 'details/:login', - getDetailsRoute: login => `details/${login}`, + PROFILE: 'profile', + PROFILE_WITH_LOGIN: 'profile/:login', + getProfileRoute: login => `profile/${login}`, }; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 769001e6bf5..576b610f2bd 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -33,7 +33,7 @@ import MainDrawerNavigator from './MainDrawerNavigator'; import { IOUBillStackNavigator, IOURequestModalStackNavigator, - DetailsModalStackNavigator, + ProfileModalStackNavigator, SearchModalStackNavigator, NewGroupModalStackNavigator, NewChatModalStackNavigator, @@ -158,9 +158,9 @@ class AuthScreens extends React.Component { component={SearchModalStackNavigator} /> ( ); -const DetailsModalStackNavigator = () => ( - ( + - - + ); const SearchModalStackNavigator = () => ( @@ -168,7 +168,7 @@ const SettingsModalStackNavigator = () => ( export { IOUBillStackNavigator, IOURequestModalStackNavigator, - DetailsModalStackNavigator, + ProfileModalStackNavigator, SearchModalStackNavigator, NewGroupModalStackNavigator, NewChatModalStackNavigator, diff --git a/src/libs/Navigation/AppNavigator/ModalStacks/index.js b/src/libs/Navigation/AppNavigator/ModalStacks/index.js index 89a8cf1ee59..ed7c42f8a51 100644 --- a/src/libs/Navigation/AppNavigator/ModalStacks/index.js +++ b/src/libs/Navigation/AppNavigator/ModalStacks/index.js @@ -5,7 +5,7 @@ const SettingsModalStack = createCustomModalStackNavigator(); const NewChatModalStack = createCustomModalStackNavigator(); const NewGroupModalStack = createCustomModalStackNavigator(); const SearchModalStack = createCustomModalStackNavigator(); -const DetailsModalStack = createCustomModalStackNavigator(); +const ProfileModalStack = createCustomModalStackNavigator(); const IOURequestModalStack = createCustomModalStackNavigator(); const IOUBillModalStack = createCustomModalStackNavigator(); @@ -14,7 +14,7 @@ export { NewChatModalStack, NewGroupModalStack, SearchModalStack, - DetailsModalStack, + ProfileModalStack, IOURequestModalStack, IOUBillModalStack, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js b/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js index 3b26a3efcb4..03f5e8edf31 100644 --- a/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js +++ b/src/libs/Navigation/AppNavigator/ModalStacks/index.native.js @@ -11,7 +11,7 @@ const SettingsModalStack = shouldUseCustomModalStack ? createCustomModalStackNav const NewChatModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const NewGroupModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const SearchModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); -const DetailsModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); +const ProfileModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const IOURequestModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); const IOUBillModalStack = shouldUseCustomModalStack ? createCustomModalStackNavigator() : createStackNavigator(); @@ -20,7 +20,7 @@ export { NewChatModalStack, NewGroupModalStack, SearchModalStack, - DetailsModalStack, + ProfileModalStack, IOURequestModalStack, IOUBillModalStack, }; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 7424877aa59..a7ad1099204 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -64,10 +64,10 @@ export default { Search_Root: '', }, }, - Details: { - initialRouteName: 'Details_Root', + Profile: { + initialRouteName: 'Profile_Root', screens: { - Details_Root: ROUTES.DETAILS_WITH_LOGIN, + Profile_Root: ROUTES.PROFILE_WITH_LOGIN, }, }, IOU_Request: { diff --git a/src/pages/DetailsPage.js b/src/pages/ProfilePage.js similarity index 93% rename from src/pages/DetailsPage.js rename to src/pages/ProfilePage.js index 68322d63e5d..a63ba1a6b92 100644 --- a/src/pages/DetailsPage.js +++ b/src/pages/ProfilePage.js @@ -35,7 +35,7 @@ const personalDetailsType = PropTypes.shape({ const matchType = PropTypes.shape({ params: PropTypes.shape({ - // login passed via route /details/:login + // login passed via route /profile/:login login: PropTypes.string, }), }); @@ -49,7 +49,7 @@ const propTypes = { route: matchType.isRequired, }; -const DetailsPage = ({personalDetails, route}) => { +const ProfilePage = ({personalDetails, route}) => { const profileDetails = personalDetails[route.params.login]; return ( @@ -60,7 +60,7 @@ const DetailsPage = ({personalDetails, route}) => { {profileDetails ? ( @@ -80,7 +80,7 @@ const DetailsPage = ({personalDetails, route}) => { : null} {profileDetails.login ? ( - + {Str.isSMSLogin(profileDetails.login) ? 'Phone Number' : 'Email'} @@ -92,7 +92,7 @@ const DetailsPage = ({personalDetails, route}) => { ) : null} {profileDetails.pronouns ? ( - + Preferred Pronouns @@ -102,7 +102,7 @@ const DetailsPage = ({personalDetails, route}) => { ) : null} {profileDetails.timezone ? ( - + Local Time @@ -121,11 +121,11 @@ const DetailsPage = ({personalDetails, route}) => { ); }; -DetailsPage.propTypes = propTypes; -DetailsPage.displayName = 'DetailsPage'; +ProfilePage.propTypes = propTypes; +ProfilePage.displayName = 'ProfilePage'; export default withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, }, -})(DetailsPage); +})(ProfilePage); diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 5dfbb33fb5a..41b46987dad 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -63,14 +63,13 @@ const HeaderView = props => ( onPress={() => { const {participants} = props.report; if (participants.length === 1) { - Navigation.navigate(ROUTES.getDetailsRoute(participants[0])); + Navigation.navigate(ROUTES.getProfileRoute(participants[0])); } }} + style={[styles.flexRow, styles.alignItemsCenter]} > - - -
- + +
( {/* placeholder from appearing as a selection option. */} NameValuePair.set(CONST.NVP.PRIORITY_MODE, mode, ONYXKEYS.NVP_PRIORITY_MODE) + mode => NameValuePair.set(CONST.NVP.PRIORITY_MODE, mode, ONYXKEYS.PRIORITY_MODE) } items={Object.values(priorityModes)} style={styles.picker} @@ -80,6 +80,6 @@ PreferencesPage.displayName = 'PreferencesPage'; export default withOnyx({ priorityMode: { - key: ONYXKEYS.NVP_PRIORITY_MODE, + key: ONYXKEYS.PRIORITY_MODE, }, })(PreferencesPage); diff --git a/src/styles/styles.js b/src/styles/styles.js index cfd6ce1cb7b..28e0130bc50 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1085,17 +1085,17 @@ const styles = { opacity: 0, }, - detailsPageContainer: { + profilePageContainer: { justifyContent: 'space-between', width: '100%', flex: 1, }, - detailsPageSectionContainer: { + profilePageSectionContainer: { alignSelf: 'flex-start', }, - detailsPageSectionVersion: { + profilePageSectionVersion: { alignSelf: 'center', color: themeColors.textSupporting, fontSize: variables.fontSizeSmall, From dd76c01ad0774094fcc9a24e4ba403ab872030ff Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Fri, 19 Mar 2021 10:32:47 -0700 Subject: [PATCH 09/12] update priorityMode onyx key --- src/ONYXKEYS.js | 7 ++++--- src/libs/Navigation/AppNavigator/AuthScreens.js | 2 +- src/pages/home/sidebar/SidebarLinks.js | 2 +- src/pages/settings/PreferencesPage.js | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 8edd302fb8c..488c20dce7d 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 576b610f2bd..d89e0375b42 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -69,7 +69,7 @@ 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(); User.fetch(); User.getBetas(); diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index c4215b28e65..3390f1896c9 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -181,7 +181,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 b964cb75dce..f3da3c89fa8 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); From c5fe238ea5d50f5f20a8261b6296f9598ea5dfbe Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Fri, 19 Mar 2021 14:08:56 -0700 Subject: [PATCH 10/12] use merge instead of set add priorityMode migration --- src/libs/actions/PersonalDetails.js | 4 +-- src/libs/migrations/RenamePriorityModeKey.js | 33 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/libs/migrations/RenamePriorityModeKey.js diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index beb232c1d26..4faccd19f68 100644 --- a/src/libs/actions/PersonalDetails.js +++ b/src/libs/actions/PersonalDetails.js @@ -112,7 +112,7 @@ function fetch() { }) .then((data) => { const allPersonalDetails = formatPersonalDetails(data.personalDetailsList); - Onyx.set(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails); + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails); const myPersonalDetails = allPersonalDetails[currentUserEmail] || {avatar: getAvatar(undefined, currentUserEmail)}; @@ -122,7 +122,7 @@ function fetch() { myPersonalDetails.lastName = lodashGet(data.personalDetailsList, [currentUserEmail, 'lastName'], ''); // Set my personal details so they can be easily accessed and subscribed to on their own key - Onyx.set(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails); + Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails); }) .catch(error => console.debug('Error fetching personal details', error)); } diff --git a/src/libs/migrations/RenamePriorityModeKey.js b/src/libs/migrations/RenamePriorityModeKey.js new file mode 100644 index 00000000000..c80c1058bba --- /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(); + }); + }, + }); + }); +} From 13a35e048c849695118935367606be51681bdfee Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Fri, 19 Mar 2021 15:06:18 -0700 Subject: [PATCH 11/12] include migration in all requisite areas --- src/libs/migrateOnyx.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/migrateOnyx.js b/src/libs/migrateOnyx.js index a93c50bb645..8b0d428076c 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 From ded31896602ff5f27e48eb569621ddeffe9beb8f Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Fri, 19 Mar 2021 16:06:29 -0700 Subject: [PATCH 12/12] remove extra space --- src/pages/home/HeaderView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index a22455f022f..4716530e07b 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -95,7 +95,6 @@ const HeaderView = (props) => { /> - togglePinnedState(props.report)}