Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimise composer send behaviour #30168

Merged
merged 97 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
00a7c23
perf: memoize components
hurali97 Oct 23, 2023
9c4f299
refactor: simplify props
hurali97 Oct 23, 2023
75ad613
perf: reduce re-renders
hurali97 Oct 23, 2023
d242e35
refactor: make action prop lightweight
hurali97 Oct 24, 2023
33239a6
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Oct 25, 2023
828b4eb
perf: add Interaction Manager
hurali97 Oct 25, 2023
60d3034
perf: reference bindings of functions
hurali97 Oct 25, 2023
851c61f
perf: optimise rendering
hurali97 Oct 26, 2023
e613f42
perf: optimise usage of personal detail list
hurali97 Oct 26, 2023
47c4717
fix: linting
hurali97 Oct 26, 2023
18428c1
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Oct 27, 2023
9562e8c
refactor: remove not needed code
hurali97 Oct 27, 2023
ad1b337
fix: linting and test
hurali97 Oct 27, 2023
9a27bed
fix: failing unread indicator test
hurali97 Oct 27, 2023
9f29436
fix: prettier issues
hurali97 Oct 27, 2023
352227f
fix: failing test
hurali97 Oct 27, 2023
23537f5
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Oct 30, 2023
5d0f32b
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 6, 2023
3820a45
fix: reassure failures reported
hurali97 Nov 6, 2023
ddf53d3
fix: reported reassure issues
hurali97 Nov 7, 2023
60be54d
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 7, 2023
5e2f21f
fix: reported reassure issues
hurali97 Nov 7, 2023
70eaf12
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 9, 2023
684ddda
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 13, 2023
46c9d60
fix: pr review
hurali97 Nov 13, 2023
21ee749
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 15, 2023
83d823e
fix: add default value
hurali97 Nov 16, 2023
1856820
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 17, 2023
36eaa4e
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 27, 2023
83f6bf1
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 28, 2023
67c1c0e
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 29, 2023
a7130f0
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Nov 30, 2023
fbf2729
fix: appropriate arguments to getDisplayNameOrDefault
hurali97 Nov 30, 2023
1d115c0
fix: workspace unavailable avatar
hurali97 Nov 30, 2023
3b98178
fix: pass policy instead of policies to getIcons
hurali97 Nov 30, 2023
ae3d7fe
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 1, 2023
33703b3
test: fix failing caledarpickertest due to an edge case of last month…
hurali97 Dec 1, 2023
ae6f7d2
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 1, 2023
ad2549a
fix: personal details not updating
hurali97 Dec 4, 2023
d5c837d
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 4, 2023
a99d653
fix: personalDetails not updating
hurali97 Dec 6, 2023
d9eda10
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 6, 2023
b1257f5
fix: ts issues
hurali97 Dec 6, 2023
21749f1
fix: personaldetails not updating
hurali97 Dec 7, 2023
411b92c
fix: personalDetails not updating in AnonymousReportFooter
hurali97 Dec 7, 2023
55c900f
refactor: cleanup
hurali97 Dec 7, 2023
d8c895a
refactor: cleanup
hurali97 Dec 7, 2023
3036ef8
refactor: move personalDetails to LHNOptionsList
hurali97 Dec 7, 2023
18cd5fe
fix: typescript issues
hurali97 Dec 7, 2023
65d25e8
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 11, 2023
3ff28a2
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 12, 2023
f896fc6
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 12, 2023
72a93b9
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 14, 2023
1296484
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 15, 2023
36bfec3
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 15, 2023
259a121
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 18, 2023
87e0d93
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 19, 2023
c632b7c
fix: typecheck for AvatarWithDisplayName
hurali97 Dec 19, 2023
77d273e
fix: linting
hurali97 Dec 19, 2023
de41fd0
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 21, 2023
3deb210
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 22, 2023
d8d2208
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 27, 2023
c404896
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 28, 2023
2facb91
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Dec 29, 2023
4f7cf26
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 3, 2024
d74c3aa
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 4, 2024
b3e6f68
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 4, 2024
048b8a6
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 8, 2024
c3fd89f
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 9, 2024
b215c84
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 10, 2024
15ba306
fix: paste not working on web
hurali97 Jan 10, 2024
1ab6e19
fix: compose height on mobile
hurali97 Jan 11, 2024
f45a0aa
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 11, 2024
1139e31
fix: revert platform specific styles
hurali97 Jan 11, 2024
2c6f73a
fix: extra compose height
hurali97 Jan 11, 2024
53bb609
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 15, 2024
48a0d83
fix: reply not shown
hurali97 Jan 16, 2024
c66e571
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 16, 2024
baf9b3e
fix: add missing reportAction properties
hurali97 Jan 17, 2024
e2b24a0
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 17, 2024
83a7bc2
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 17, 2024
470eb7b
fix: hide reply and task welcome message and add the missing fields
hurali97 Jan 18, 2024
efd81f5
refactor: remove not used prop
hurali97 Jan 18, 2024
f1bbd1d
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 19, 2024
722910d
fix: local time not displayed
hurali97 Jan 19, 2024
348d33a
refactor: move memoized report object to report screen
hurali97 Jan 19, 2024
d233cbb
fix: composer not being auto focused
hurali97 Jan 24, 2024
16c0ad6
refactor: remove not needed code change
hurali97 Jan 24, 2024
ddb5ef6
fix: linting
hurali97 Jan 24, 2024
17a5cda
fix: reassure tests
hurali97 Jan 24, 2024
3943fa4
refactor: add prop types
hurali97 Jan 24, 2024
1eccb29
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 25, 2024
a172b68
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 26, 2024
336a0a3
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 30, 2024
e840080
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 30, 2024
da78bf0
fix: crash and profile not updating
hurali97 Jan 31, 2024
d2e771d
Merge branch 'main' of https://github.com/hurali97/Expensify-App into…
hurali97 Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/components/AnonymousReportFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Session from '@userActions/Session';
import type {PersonalDetailsList, Report} from '@src/types/onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy, Report} from '@src/types/onyx';
import AvatarWithDisplayName from './AvatarWithDisplayName';
import Button from './Button';
import ExpensifyWordmark from './ExpensifyWordmark';
import Text from './Text';

type AnonymousReportFooterProps = {
type AnonymousReportFooterPropsWithOnyx = {
/** The policy which the user has access to and which the report is tied to */
policy: OnyxEntry<Policy>;
};

type AnonymousReportFooterProps = AnonymousReportFooterPropsWithOnyx & {
/** The report currently being looked at */
report: OnyxEntry<Report>;

/** Whether the small screen size layout should be used */
isSmallSizeLayout?: boolean;

/** Personal details of all the users */
personalDetails: OnyxEntry<PersonalDetailsList>;
};

function AnonymousReportFooter({isSmallSizeLayout = false, personalDetails, report}: AnonymousReportFooterProps) {
function AnonymousReportFooter({isSmallSizeLayout = false, report, policy}: AnonymousReportFooterProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand All @@ -30,9 +34,9 @@ function AnonymousReportFooter({isSmallSizeLayout = false, personalDetails, repo
<View style={[styles.flexRow, styles.flexShrink1]}>
<AvatarWithDisplayName
report={report}
personalDetails={personalDetails}
isAnonymous
shouldEnableDetailPageNavigation
policy={policy}
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. not sure how real time update used to work without policy prop before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can explain. Previously, we were passing the policies prop to ReportFooter and it has ReportAnonymousFooter as a child so it re-renders whenever policies update. But since I removed that altogether, it was not updating in real-time anymore. So I decided to use the dedicated policy in the nearest component possible.

/>
</View>
<View style={styles.anonymousRoomFooterWordmarkAndLogoContainer(isSmallSizeLayout)}>
Expand All @@ -57,4 +61,8 @@ function AnonymousReportFooter({isSmallSizeLayout = false, personalDetails, repo

AnonymousReportFooter.displayName = 'AnonymousReportFooter';

export default AnonymousReportFooter;
export default withOnyx<AnonymousReportFooterProps, AnonymousReportFooterPropsWithOnyx>({
policy: {
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`,
},
})(AnonymousReportFooter);
4 changes: 2 additions & 2 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Str from 'expensify-common/lib/str';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import React, {memo, useCallback, useEffect, useMemo, useState} from 'react';
import {Animated, Keyboard, View} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -610,6 +610,6 @@ export default withOnyx<AttachmentModalProps, AttachmentModalOnyxProps>({
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`,
canEvict: false,
},
})(AttachmentModal);
})(memo(AttachmentModal));

export type {Attachment};
15 changes: 9 additions & 6 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import useStyleUtils from '@hooks/useStyleUtils';
Expand All @@ -12,7 +12,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {PersonalDetails, PersonalDetailsList, Policy, Report, ReportActions} from '@src/types/onyx';
import type {PersonalDetails, Policy, Report, ReportActions} from '@src/types/onyx';
import DisplayNames from './DisplayNames';
import MultipleAvatars from './MultipleAvatars';
import ParentNavigationSubtitle from './ParentNavigationSubtitle';
Expand All @@ -23,6 +23,9 @@ import Text from './Text';
type AvatarWithDisplayNamePropsWithOnyx = {
/** All of the actions of the report */
parentReportActions: OnyxEntry<ReportActions>;

/** Personal details of all users */
personalDetails: OnyxCollection<PersonalDetails>;
};

type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
Expand All @@ -35,9 +38,6 @@ type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
/** The size of the avatar */
size?: ValueOf<typeof CONST.AVATAR_SIZE>;

/** Personal details of all the users */
personalDetails: OnyxEntry<PersonalDetailsList>;

/** Whether if it's an unauthenticated user */
isAnonymous?: boolean;

Expand All @@ -46,13 +46,13 @@ type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
};

function AvatarWithDisplayName({
personalDetails,
policy,
report,
parentReportActions,
isAnonymous = false,
size = CONST.AVATAR_SIZE.DEFAULT,
shouldEnableDetailPageNavigation = false,
personalDetails = CONST.EMPTY_OBJECT,
}: AvatarWithDisplayNameProps) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -181,4 +181,7 @@ export default withOnyx<AvatarWithDisplayNameProps, AvatarWithDisplayNamePropsWi
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`,
canEvict: false,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
})(AvatarWithDisplayName);
4 changes: 2 additions & 2 deletions src/components/EmojiPicker/EmojiPickerButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, {useEffect, useRef} from 'react';
import React, {memo, useEffect, useRef} from 'react';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
Expand Down Expand Up @@ -87,4 +87,4 @@ function EmojiPickerButton(props) {
EmojiPickerButton.propTypes = propTypes;
EmojiPickerButton.defaultProps = defaultProps;
EmojiPickerButton.displayName = 'EmojiPickerButton';
export default compose(withLocalize, withNavigationFocus)(EmojiPickerButton);
export default compose(withLocalize, withNavigationFocus)(memo(EmojiPickerButton));
4 changes: 2 additions & 2 deletions src/components/ExceededCommentLength.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {memo} from 'react';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
Expand All @@ -20,4 +20,4 @@ function ExceededCommentLength() {

ExceededCommentLength.displayName = 'ExceededCommentLength';

export default ExceededCommentLength;
export default memo(ExceededCommentLength);
2 changes: 0 additions & 2 deletions src/components/HeaderWithBackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function HeaderWithBackButton({
onThreeDotsButtonPress = () => {},
report = null,
policy,
personalDetails = null,
shouldShowAvatarWithDisplay = false,
shouldShowBackButton = true,
shouldShowBorderBottom = false,
Expand Down Expand Up @@ -104,7 +103,6 @@ function HeaderWithBackButton({
<AvatarWithDisplayName
report={report}
policy={policy}
personalDetails={personalDetails}
shouldEnableDetailPageNavigation={shouldEnableDetailPageNavigation}
/>
) : (
Expand Down
7 changes: 3 additions & 4 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type DeepValueOf from '@src/types/utils/DeepValueOf';
import Button from './Button';
import HeaderWithBackButton from './HeaderWithBackButton';
import MoneyReportHeaderStatusBar from './MoneyReportHeaderStatusBar';
import {usePersonalDetails} from './OnyxProvider';
import SettlementButton from './SettlementButton';

type PaymentType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
Expand All @@ -43,12 +44,10 @@ type MoneyReportHeaderProps = MoneyReportHeaderOnyxProps & {

/** The policy tied to the money request report */
policy: OnyxTypes.Policy;

/** Personal details so we can get the ones for the report participants */
personalDetails: OnyxTypes.PersonalDetailsList;
};

function MoneyReportHeader({session, personalDetails, policy, chatReport, nextStep, report: moneyRequestReport}: MoneyReportHeaderProps) {
function MoneyReportHeader({session, policy, chatReport, nextStep, report: moneyRequestReport}: MoneyReportHeaderProps) {
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT;
const styles = useThemeStyles();
const {translate} = useLocalize();
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
Expand Down
8 changes: 3 additions & 5 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ConfirmModal from './ConfirmModal';
import HeaderWithBackButton from './HeaderWithBackButton';
import * as Expensicons from './Icon/Expensicons';
import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar';
import participantPropTypes from './participantPropTypes';
import {usePersonalDetails} from './OnyxProvider';
import transactionPropTypes from './transactionPropTypes';

const propTypes = {
Expand All @@ -35,9 +35,6 @@ const propTypes = {
name: PropTypes.string,
}),

/** Personal details so we can get the ones for the report participants */
personalDetails: PropTypes.objectOf(participantPropTypes).isRequired,

/* Onyx Props */
/** Session info for the currently logged in user. */
session: PropTypes.shape({
Expand Down Expand Up @@ -65,7 +62,8 @@ const defaultProps = {
policy: {},
};

function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, policy, personalDetails}) {
function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, policy}) {
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT;
const styles = useThemeStyles();
const {translate} = useLocalize();
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
Expand Down
8 changes: 8 additions & 0 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,15 @@ function getEffectiveDisplayName(personalDetail?: PersonalDetails): string | und
return undefined;
}

/**
* Whether personal details is empty
*/
function isPersonalDetailsEmpty() {
return !personalDetails.length;
}

export {
isPersonalDetailsEmpty,
getDisplayNameOrDefault,
getPersonalDetailsByIDs,
getAccountIDsByLogins,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function ReportDetailsPage(props) {
return ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participants, props.personalDetails), hasMultipleParticipants);
}, [participants, props.personalDetails]);

const icons = useMemo(() => ReportUtils.getIcons(props.report, props.personalDetails, props.policies), [props.report, props.personalDetails, props.policies]);
const icons = useMemo(() => ReportUtils.getIcons(props.report, props.personalDetails, null, '', -1, policy), [props.report, props.personalDetails, policy]);

const chatRoomSubtitleText = chatRoomSubtitle ? (
<DisplayNames
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,8 @@ export default memo(
},
selector: (policy) => _.pick(policy, ['role']),
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
})(HeaderView),
);
Loading
Loading