From 5020b41f9934820c591dd176dc15b1cd04c95ff0 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 18 Oct 2021 15:45:56 +0100 Subject: [PATCH 1/3] replace unnecessary personalDetailsPropType redeclaration --- src/pages/NewChatPage.js | 23 +++++-------------- src/pages/NewGroupPage.js | 15 ++---------- src/pages/SearchPage.js | 15 ++---------- .../IOUParticipantsRequest.js | 15 ++---------- .../IOUParticipantsSplit.js | 15 ++---------- 5 files changed, 14 insertions(+), 69 deletions(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index c21888389af0..b1b4ad44c503 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -16,27 +16,14 @@ import ScreenWrapper from '../components/ScreenWrapper'; import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; - -const personalDetailsPropTypes = PropTypes.shape({ - /** The login of the person (either email or phone number) */ - login: PropTypes.string.isRequired, - - /** The URL of the person's avatar (there should already be a default avatar if - the person doesn't have their own avatar uploaded yet) */ - avatar: PropTypes.string.isRequired, - - /** This is either the user's full name, or their login if full name is an empty string */ - displayName: PropTypes.string.isRequired, - - ...withLocalizePropTypes, -}); +import personalDetailsPropType from './personalDetailsPropType'; const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string).isRequired, - - /** All of the personal details for everyone */ - personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired, + + /** The personal details of the person who is logged in */ + personalDetails: personalDetailsPropType.isRequired, /** All reports shared with the user */ reports: PropTypes.shape({ @@ -50,6 +37,8 @@ const propTypes = { }).isRequired, ...windowDimensionsPropTypes, + + ...withLocalizePropTypes, }; class NewChatPage extends Component { diff --git a/src/pages/NewGroupPage.js b/src/pages/NewGroupPage.js index 739acf7ade3b..399da0e89ec1 100755 --- a/src/pages/NewGroupPage.js +++ b/src/pages/NewGroupPage.js @@ -19,25 +19,14 @@ import compose from '../libs/compose'; import Button from '../components/Button'; import KeyboardAvoidingView from '../components/KeyboardAvoidingView'; import FixedFooter from '../components/FixedFooter'; - -const personalDetailsPropTypes = PropTypes.shape({ - /** The login of the person (either email or phone number) */ - login: PropTypes.string.isRequired, - - /** The URL of the person's avatar (there should already be a default avatar if - the person doesn't have their own avatar uploaded yet) */ - avatar: PropTypes.string.isRequired, - - /** This is either the user's full name, or their login if full name is an empty string */ - displayName: PropTypes.string.isRequired, -}); +import personalDetailsPropType from './personalDetailsPropType'; const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string).isRequired, /** All of the personal details for everyone */ - personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired, + personalDetails: personalDetailsPropType.isRequired, /** All reports shared with the user */ reports: PropTypes.shape({ diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 03b6679deab4..9e6aee3c7193 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -19,18 +19,7 @@ import CONST from '../CONST'; import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; - -const personalDetailsPropTypes = PropTypes.shape({ - /** The login of the person (either email or phone number) */ - login: PropTypes.string.isRequired, - - /** The URL of the person's avatar (there should already be a default avatar if - the person doesn't have their own avatar uploaded yet) */ - avatar: PropTypes.string.isRequired, - - /** This is either the user's full name, or their login if full name is an empty string */ - displayName: PropTypes.string.isRequired, -}); +import personalDetailsPropType from './personalDetailsPropType'; const propTypes = { /* Onyx Props */ @@ -39,7 +28,7 @@ const propTypes = { betas: PropTypes.arrayOf(PropTypes.string).isRequired, /** All of the personal details for everyone */ - personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired, + personalDetails: personalDetailsPropType.isRequired, /** All reports shared with the user */ reports: PropTypes.shape({ diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index ead69898fdad..2a108b78f8c7 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -8,18 +8,7 @@ import ONYXKEYS from '../../../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; import compose from '../../../../libs/compose'; import {EXCLUDED_IOU_EMAILS} from '../../../../CONST'; - -const personalDetailsPropTypes = PropTypes.shape({ - /** The login of the person (either email or phone number) */ - login: PropTypes.string.isRequired, - - /** The URL of the person's avatar (there should already be a default avatar if the person doesn't have - * their own avatar uploaded yet) */ - avatar: PropTypes.string.isRequired, - - /** This is either the user's full name, or their login if full name is an empty string */ - displayName: PropTypes.string.isRequired, -}); +import personalDetailsPropType from '../../../personalDetailsPropType'; const propTypes = { /** Beta features list */ @@ -32,7 +21,7 @@ const propTypes = { onAddParticipants: PropTypes.func.isRequired, /** All of the personal details for everyone */ - personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired, + personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired, /** All reports shared with the user */ reports: PropTypes.shape({ diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index 614a28649293..92cbc3cfd811 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -13,18 +13,7 @@ import compose from '../../../../libs/compose'; import Button from '../../../../components/Button'; import Text from '../../../../components/Text'; import FixedFooter from '../../../../components/FixedFooter'; - -const personalDetailsPropTypes = PropTypes.shape({ - // The login of the person (either email or phone number) - login: PropTypes.string.isRequired, - - // The URL of the person's avatar (there should already be a default avatar if - // the person doesn't have their own avatar uploaded yet) - avatar: PropTypes.string.isRequired, - - // This is either the user's full name, or their login if full name is an empty string - displayName: PropTypes.string.isRequired, -}); +import personalDetailsPropType from '../../../personalDetailsPropType'; const propTypes = { /** Beta features list */ @@ -51,7 +40,7 @@ const propTypes = { })), /** All of the personal details for everyone */ - personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired, + personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired, /** All reports shared with the user */ reports: PropTypes.shape({ From 337e6618db6afe5c0d5f08162d978a6fe62e45b8 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 18 Oct 2021 15:46:25 +0100 Subject: [PATCH 2/3] update missleading comment --- src/pages/NewChatPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index b1b4ad44c503..9a87d45184a1 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -22,7 +22,7 @@ const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string).isRequired, - /** The personal details of the person who is logged in */ + /** All of the personal details for everyone */ personalDetails: personalDetailsPropType.isRequired, /** All reports shared with the user */ From 37dd76058b5e8514eba280a6dfea663bbb25b41c Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 18 Oct 2021 15:47:12 +0100 Subject: [PATCH 3/3] remove trailing space from propType --- src/pages/NewChatPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index 9a87d45184a1..c9f246396bf3 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -21,7 +21,7 @@ import personalDetailsPropType from './personalDetailsPropType'; const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string).isRequired, - + /** All of the personal details for everyone */ personalDetails: personalDetailsPropType.isRequired,