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

[HOLD] Comment linking #8638

Closed
wants to merge 120 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
88cf9a0
trying something
chiragsalian Apr 13, 2022
c3cead4
Revert "trying something"
chiragsalian Apr 13, 2022
b9ba1a8
trying scroll to index
chiragsalian Apr 13, 2022
092cd54
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Apr 14, 2022
7f398e0
trying some stuff
chiragsalian Apr 19, 2022
79dbeb5
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Apr 19, 2022
87f265a
trying more things
chiragsalian Apr 20, 2022
7c33dce
still trying
chiragsalian Apr 20, 2022
dd112ea
getting marcs changes over here
chiragsalian Apr 21, 2022
44107a4
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Apr 21, 2022
c555567
getting shouldMeasureItems key back
chiragsalian Apr 21, 2022
5f54dec
Using measurementPadding prop to make the logic easier to understand
chiragsalian Apr 21, 2022
ffa360e
removing some test artifacts
chiragsalian Apr 21, 2022
a726bf2
Updating method name to make it more obvious what it does
chiragsalian Apr 21, 2022
acedf55
Adding new route and screen
chiragsalian Apr 22, 2022
0a34329
updating maindrawernavigator to work with new screen
chiragsalian Apr 22, 2022
000e9e9
passing reportActionID
chiragsalian Apr 22, 2022
c0645ec
loading more chats as needed and scrolling to them
chiragsalian Apr 22, 2022
58e29ae
renaming to const
chiragsalian Apr 22, 2022
aa719a7
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Apr 26, 2022
a91512c
passing isSelected to ReportActionItem for highlighting
chiragsalian Apr 26, 2022
1d8b816
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Apr 27, 2022
768d182
animate background
chiragsalian Apr 27, 2022
e2515ef
Add URL to clipboard
chiragsalian Apr 27, 2022
44df461
removing actionID from route
chiragsalian Apr 27, 2022
284510c
correcting clipboard URL
chiragsalian Apr 27, 2022
406e0f3
Have link open in same session
chiragsalian Apr 28, 2022
f0c237c
working code to have scroll work for actions in same report screen
chiragsalian Apr 29, 2022
2c5f036
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 2, 2022
38fcacb
updates to support the new ReportActionsList
chiragsalian May 2, 2022
e505a41
remove debug
chiragsalian May 3, 2022
02971bf
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 3, 2022
fa0429e
navigation test to have drawer closed on simulator
chiragsalian May 4, 2022
39636da
working code to scroll to rendered comments for mobile and web
chiragsalian May 4, 2022
2dee013
background animation working better
chiragsalian May 5, 2022
2f6b424
working animation when the comment is close to the bottom
chiragsalian May 5, 2022
a6cbf5f
cleanup and comments
chiragsalian May 5, 2022
a36ba6a
BaseInvertedFlastList cleanup
chiragsalian May 5, 2022
a38583a
cleanup
chiragsalian May 5, 2022
cf86da6
cleanup
chiragsalian May 5, 2022
74f3626
cleanup
chiragsalian May 5, 2022
861c21d
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 5, 2022
c1e0e48
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 18, 2022
e7e8cac
support for getenv urls
chiragsalian May 18, 2022
a1330c9
updating clipboard copy to have it work for any environment
chiragsalian May 18, 2022
98923cc
cleanup
chiragsalian May 18, 2022
0ec6319
cleanup
chiragsalian May 18, 2022
9ca9cf6
build dev url using dynamic port logic
chiragsalian May 18, 2022
e69b719
fix for anchor rendered to work with any port
chiragsalian May 18, 2022
6a3ef3a
anchor renderer fix
chiragsalian May 19, 2022
386e98b
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 19, 2022
44b686b
cleanup
chiragsalian May 19, 2022
d56b71b
trying some drawer stuff
chiragsalian May 20, 2022
bde0075
trying some drawer stuff on ios
chiragsalian May 20, 2022
24659d7
trying to figure out dispatch flow
chiragsalian May 20, 2022
2a00456
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 23, 2022
1cfd18a
console logs
chiragsalian May 24, 2022
7c97f12
more logs
chiragsalian May 24, 2022
891cf0d
closing drawer in report screen
chiragsalian May 24, 2022
4c09166
removing test logs
chiragsalian May 24, 2022
6e458a0
revert open drawer prop
chiragsalian May 24, 2022
4be820b
cleanup
chiragsalian May 24, 2022
2b7deae
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 24, 2022
993c0f1
updating background color
chiragsalian May 24, 2022
97ca234
couple of bug fixes
chiragsalian May 25, 2022
3295c4e
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 25, 2022
a01990b
color update
chiragsalian May 25, 2022
f0c9c92
correct native measurement logic to fire early
chiragsalian May 25, 2022
e0816dd
fixing autoscroll reset value since its set in constructor and preven…
chiragsalian May 25, 2022
2beaa4e
setting doneMeasurement when loading chats so thats its not incorrect…
chiragsalian May 25, 2022
7e54987
bug fixes and more comments
chiragsalian May 25, 2022
756a9f7
removing debugging consoles
chiragsalian May 25, 2022
8ad706b
cleanups
chiragsalian May 26, 2022
c478e6b
Merge branch 'main' into chirag-comment-linking-2
chiragsalian May 31, 2022
fa1829e
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 1, 2022
719ec04
move check for closeDrawer to componentDidUpdate
chiragsalian Jun 1, 2022
ed8547a
getting radix back since its part of our lint
chiragsalian Jun 1, 2022
8fa2c4a
more readable params for ReportActionsView
chiragsalian Jun 1, 2022
88f7c2c
more readable params for ReportActionsList
chiragsalian Jun 1, 2022
95f794a
more readable params for ReportActionItem
chiragsalian Jun 1, 2022
aca301c
minor bug fixes
chiragsalian Jun 1, 2022
6ad2271
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 2, 2022
68339fc
Update src/pages/home/report/ReportActionsView.js
chiragsalian Jun 2, 2022
9c7d1f8
cleanup
chiragsalian Jun 2, 2022
cadf4a7
Merge branch 'chirag-comment-linking-2' of github.com:Expensify/App i…
chiragsalian Jun 2, 2022
a616d92
Update src/pages/home/report/ReportActionsView.js
chiragsalian Jun 2, 2022
3626a3b
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 10, 2022
aa57ca7
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 14, 2022
7dbc386
remove artificial 3 attempt limit
chiragsalian Jun 14, 2022
44b4d54
fixes so that animation works on mount as well
chiragsalian Jun 14, 2022
8aacd3e
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 14, 2022
7c329ab
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 21, 2022
d3221f1
revert some changes since they are handled in another PR
chiragsalian Jun 21, 2022
c65848d
revert line breaks and copy link feature
chiragsalian Jun 21, 2022
a298497
removing unused lib
chiragsalian Jun 21, 2022
aab906e
need dev const and internalNewExpensifyPath to recognize dev url
chiragsalian Jun 21, 2022
c6c5cac
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 22, 2022
0cb9829
dev regex const
chiragsalian Jun 23, 2022
1fff2ed
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 23, 2022
1150f3a
moving animation to componentDidUpdate instead of render
chiragsalian Jun 24, 2022
0fb83f6
rename and keeping string for reportActionID
chiragsalian Jun 24, 2022
f2e0af8
minor cleanup
chiragsalian Jun 24, 2022
f7415aa
trying something different to simplify code
chiragsalian Jun 25, 2022
3ed10b0
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 25, 2022
115145f
cleanup
chiragsalian Jun 26, 2022
81b5a3e
some more cleanups
chiragsalian Jun 26, 2022
80fca12
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 27, 2022
622269a
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 28, 2022
7fed32c
testing navigation fixes
chiragsalian Jun 28, 2022
7e799d1
removing debug code
chiragsalian Jun 28, 2022
1ebfefa
working code using linkTo
chiragsalian Jun 29, 2022
7816878
Navigation fixes
chiragsalian Jun 29, 2022
70633f1
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jun 29, 2022
b42db8d
oops lint fix
chiragsalian Jun 30, 2022
057396a
minor revert and cleanup
chiragsalian Jun 30, 2022
6369ba7
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jul 7, 2022
4bd36a5
comment linking beta
chiragsalian Jul 7, 2022
8f2e11e
allow comment linking to work only if user is part of beta
chiragsalian Jul 7, 2022
b0cf8a0
Merge branch 'main' into chirag-comment-linking-2
chiragsalian Jul 8, 2022
cc67fb7
Correct a test change
chiragsalian Jul 8, 2022
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
2 changes: 2 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const CONST = {
IOU_SEND: 'sendMoney',
POLICY_ROOMS: 'policyRooms',
POLICY_EXPENSE_CHAT: 'policyExpenseChat',
COMMENT_LINKING: 'commentLinking',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down Expand Up @@ -222,6 +223,7 @@ const CONST = {

// Use Environment.getEnvironmentURL to get the complete URL with port number
DEV_NEW_EXPENSIFY_URL: 'http://localhost:',
chiragsalian marked this conversation as resolved.
Show resolved Hide resolved
DEV_NEW_EXPENSIFY_URL_WITH_PORT_REGEX: /^[a-z]{4,5}:\/{2}[a-z]{1,}:[0-9]{1,4}\//,

OPTION_TYPE: {
REPORT: 'report',
Expand Down
6 changes: 4 additions & 2 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {
NEW_GROUP: 'new/group',
NEW_CHAT: 'new/chat',
REPORT,
REPORT_WITH_ID: 'r/:reportID',
REPORT_WITH_ID: 'r/:reportID/:reportActionID?',
Julesssss marked this conversation as resolved.
Show resolved Hide resolved
getReportRoute: reportID => `r/${reportID}`,
IOU_REQUEST,
IOU_BILL,
Expand Down Expand Up @@ -128,7 +128,9 @@ export default {
const pathSegments = route.split('/');
return {
reportID: lodashGet(pathSegments, 1),
isParticipantsRoute: Boolean(lodashGet(pathSegments, 2)),
isParticipantsRoute: lodashGet(pathSegments, 2) === 'participants',
isDetailsRoute: lodashGet(pathSegments, 2) === 'details',
isSettingsRoute: lodashGet(pathSegments, 2) === 'settings',
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ const AnchorRenderer = (props) => {
const displayName = lodashGet(props.tnode, 'domNode.children[0].data', '');
const parentStyle = lodashGet(props.tnode, 'parent.styles.nativeTextRet', {});
const attrHref = htmlAttribs.href || '';
const internalNewExpensifyPath = (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, ''))
|| (attrHref.startsWith(CONST.STAGING_NEW_EXPENSIFY_URL) && attrHref.replace(CONST.STAGING_NEW_EXPENSIFY_URL, ''));
const internalNewExpensifyPath = (attrHref.startsWith(CONST.DEV_NEW_EXPENSIFY_URL) && attrHref.replace(CONST.DEV_NEW_EXPENSIFY_URL_WITH_PORT_REGEX, ''))
|| (attrHref.startsWith(CONST.STAGING_NEW_EXPENSIFY_URL) && attrHref.replace(CONST.STAGING_NEW_EXPENSIFY_URL, ''))
|| (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, ''));
const internalExpensifyPath = attrHref.startsWith(CONFIG.EXPENSIFY.EXPENSIFY_URL) && attrHref.replace(CONFIG.EXPENSIFY.EXPENSIFY_URL, '');

// If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation
Expand Down
46 changes: 36 additions & 10 deletions src/components/InvertedFlatList/BaseInvertedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ const propTypes = {

/** Should we remove the clipped sub views? */
shouldRemoveClippedSubviews: PropTypes.bool,

/** Padding that we should account for in our sizeMap */
measurementPadding: PropTypes.number,

/** Callback for when measurement is done */
onMeasurementEnd: PropTypes.func,
};

const defaultProps = {
data: [],
shouldMeasureItems: false,
shouldRemoveClippedSubviews: false,
measurementPadding: 0,
onMeasurementEnd: () => {},
};

class BaseInvertedFlatList extends Component {
Expand Down Expand Up @@ -96,22 +104,36 @@ class BaseInvertedFlatList extends Component {
measureItemLayout(nativeEvent, index) {
const computedHeight = nativeEvent.layout.height;

// We've already measured this item so we don't need to
// measure it again.
if (this.sizeMap[index]) {
// Before an item is rendered on screen its possible its computedHeight is 0 so let's return early and once its rendered it will it this method again with proper values.
if (computedHeight === 0) {
marcaaron marked this conversation as resolved.
Show resolved Hide resolved
return;
}

const previousItem = this.sizeMap[index - 1] || {};
// We've already measured this item so we don't need to measure it again.
if (this.sizeMap[index]) {
return;
}

// If there is no previousItem this can mean we haven't yet measured
// the previous item or that we are at index 0 and there is no previousItem
const previousLength = previousItem.length || 0;
const previousOffset = previousItem.offset || 0;
this.sizeMap[index] = {
length: computedHeight,
offset: previousLength + previousOffset,
};

if (_.size(this.sizeMap) === this.props.data.length) {
chiragsalian marked this conversation as resolved.
Show resolved Hide resolved
// All items have been measured so update the offset now that we have all heights
for (let i = 0; i < this.props.data.length; i++) {
// If there is no previousItem we are at index 0 and there is no previousItem
const previousItem = this.sizeMap[i - 1] || {};

if (i === 0 && this.props.measurementPadding) {
this.sizeMap[0].length += this.props.measurementPadding;
}

const previousLength = previousItem.length || 0;
const previousOffset = previousItem.offset || 0;
this.sizeMap[i].offset = previousLength + previousOffset;
}
this.props.onMeasurementEnd();
}
}

/**
Expand All @@ -134,7 +156,10 @@ class BaseInvertedFlatList extends Component {
);
}

return this.props.renderItem({item, index});
// For native platforms, for scrollIndex to work properly since we're not measuring items we'll want to track
// when the reportActionID is rendered so that we can scroll to it.
const shouldTrackItemRendered = true;
return this.props.renderItem({item, index, shouldTrackItemRendered});
}

render() {
Expand All @@ -155,6 +180,7 @@ class BaseInvertedFlatList extends Component {
windowSize={15}
removeClippedSubviews={this.props.shouldRemoveClippedSubviews}
maintainVisibleContentPosition={{minIndexForVisible: 0, autoscrollToTopThreshold: 0}}
onScrollToIndexFailed={() => {}}
chiragsalian marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}
Expand Down
15 changes: 11 additions & 4 deletions src/libs/Navigation/CustomActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@ function pushDrawerRoute(route) {
navigateBackToRootDrawer();
}

// If we're trying to navigate to the same screen that is already active there's nothing more to do except close the drawer.
// This prevents unnecessary re-rendering the screen and adding duplicate items to the browser history.
const activeState = getActiveState();
const activeScreenName = getScreenNameFromState(activeState);
const activeScreenParams = getParamsFromState(activeState);
if (newScreenName === activeScreenName && _.isEqual(activeScreenParams, newScreenParams)) {
return DrawerActions.closeDrawer();
if (newScreenName === activeScreenName && activeScreenParams.reportID === newScreenParams.reportID) {
// If we're trying to navigate to the same screen that is already active there's nothing more to do except close the drawer.
// This prevents unnecessary re-rendering the screen and adding duplicate items to the browser history.
if (!newScreenParams.reportActionID) {
return DrawerActions.closeDrawer();
}

// If we're trying to navigate to the same screen with a new prop then let's just set the new params and not reset the navigation.
if (activeScreenParams.reportActionID !== newScreenParams.reportActionID) {
return CommonActions.setParams(newScreenParams);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only set the params when they change and since we are only listening for "changes" in the component I think this is why we can't navigate to the same report action again if the params are already in the URL. So, something about this code needs to change.

Copy link
Contributor Author

@chiragsalian chiragsalian Jul 8, 2022

Choose a reason for hiding this comment

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

Cool, firstly its part of known limitations captured above,

Click on a same link that was already animated before will not do anything since the URL does not change.

Next,

I think this is why we can't navigate..

Perhaps. Right now in ReportActionsView -> componentDidUpdate i'm not scrolling if the reportActionID is unchanged. When the time comes to address this i was hoping to post a plan of action to confirm the changes and then update accordingly.

}

let state = currentState;
Expand Down
11 changes: 8 additions & 3 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function goBack(shouldOpenDrawer = true) {
}

/**
* We navigate to the certains screens with a custom action so that we can preserve the browser history in web. react-navigation does not handle this well
* We navigate to the certain screens with a custom action so that we can preserve the browser history in web. react-navigation does not handle this well
* and only offers a "mobile" navigation paradigm e.g. in order to add a history item onto the browser history stack one would need to use the "push" action.
* However, this is not performant as it would keep stacking ReportScreen instances (which are quite expensive to render).
* We're also looking to see if we have a participants route since those also have a reportID param, but do not have the problem described above and should not use the custom action.
Expand All @@ -114,8 +114,13 @@ function goBack(shouldOpenDrawer = true) {
* @returns {Boolean}
*/
function isDrawerRoute(route) {
const {reportID, isParticipantsRoute} = ROUTES.parseReportRouteParams(route);
return reportID && !isParticipantsRoute;
const {
reportID,
isParticipantsRoute,
isDetailsRoute,
isSettingsRoute,
} = ROUTES.parseReportRouteParams(route);
return reportID && !isParticipantsRoute && !isDetailsRoute && !isSettingsRoute;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/libs/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ function canUsePolicyExpenseChat(betas) {
return _.contains(betas, CONST.BETAS.POLICY_EXPENSE_CHAT) || canUseAllBetas(betas);
}

/**
* @param {Array<String>} betas
* @returns {Boolean}
*/
function canUseCommentLinking(betas) {
return _.contains(betas, CONST.BETAS.COMMENT_LINKING) || canUseAllBetas(betas);
}

export default {
canUseChronos,
canUseIOU,
Expand All @@ -96,4 +104,5 @@ export default {
canUseWallet,
canUsePolicyRooms,
canUsePolicyExpenseChat,
canUseCommentLinking,
};
4 changes: 4 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const propTypes = {
params: PropTypes.shape({
/** The ID of the report this screen should display */
reportID: PropTypes.string,

/** The reportActionID to scroll to */
reportActionID: PropTypes.string,
}).isRequired,
}).isRequired,

Expand Down Expand Up @@ -229,6 +232,7 @@ class ReportScreen extends React.Component {
{!this.shouldShowLoader() && (
<ReportActionsView
reportID={reportID}
reportActionID={Permissions.canUseCommentLinking(this.props.betas) ? this.props.route.params.reportActionID : ''}
reportActions={this.props.reportActions}
report={this.props.report}
session={this.props.session}
Expand Down
49 changes: 46 additions & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'underscore';
import lodashGet from 'lodash/get';
import React, {Component} from 'react';
import {withOnyx} from 'react-native-onyx';
import {View} from 'react-native';
import {View, Animated} from 'react-native';
import PropTypes from 'prop-types';
import CONST from '../../../CONST';
import ONYXKEYS from '../../../ONYXKEYS';
Expand All @@ -28,6 +28,7 @@ import {withNetwork, withReportActionsDrafts} from '../../../components/OnyxProv
import RenameAction from '../../../components/ReportActionItem/RenameAction';
import InlineSystemMessage from '../../../components/InlineSystemMessage';
import styles from '../../../styles/styles';
import colors from '../../../styles/colors';

const propTypes = {
/** The ID of the report this action is on. */
Expand All @@ -54,6 +55,12 @@ const propTypes = {
/** Draft message - if this is set the comment is in 'edit' mode */
draftMessage: PropTypes.string,

/** Should we highlight the current report action item */
shouldHighlight: PropTypes.bool.isRequired,

/** Callback for when the item is rendered */
onItemRendered: PropTypes.func.isRequired,

...windowDimensionsPropTypes,
};

Expand All @@ -71,6 +78,20 @@ class ReportActionItem extends Component {
};
this.checkIfContextMenuActive = this.checkIfContextMenuActive.bind(this);
this.showPopover = this.showPopover.bind(this);
this.animatedBackgroundColor = new Animated.Value(0);
const interpolatedBackgroundColor = this.animatedBackgroundColor.interpolate(
{
inputRange: [0, 1],
outputRange: [colors.white, colors.honeydew],
},
);
this.animatedBackgroundStyle = {
backgroundColor: interpolatedBackgroundColor,
};
}
Julesssss marked this conversation as resolved.
Show resolved Hide resolved

componentDidMount() {
this.props.onItemRendered(this.props.action.reportActionID);
}

shouldComponentUpdate(nextProps, nextState) {
Expand All @@ -80,10 +101,15 @@ class ReportActionItem extends Component {
|| this.props.hasOutstandingIOU !== nextProps.hasOutstandingIOU
|| this.props.shouldDisplayNewIndicator !== nextProps.shouldDisplayNewIndicator
|| !_.isEqual(this.props.action, nextProps.action)
|| !_.isEqual(this.props.shouldHighlight, nextProps.shouldHighlight)
|| this.state.isContextMenuActive !== nextState.isContextMenuActive;
}
Julesssss marked this conversation as resolved.
Show resolved Hide resolved

componentDidUpdate(prevProps) {
if (this.props.shouldHighlight) {
this.animateBackground();
}

if (prevProps.draftMessage || !this.props.draftMessage) {
return;
}
Expand All @@ -92,6 +118,23 @@ class ReportActionItem extends Component {
this.textInput.focus();
}

/**
* Animate the background of the item
*/
animateBackground() {
Animated.timing(this.animatedBackgroundColor, {
toValue: 1,
duration: 0,
useNativeDriver: false,
}).start(() => {
Animated.timing(this.animatedBackgroundColor, {
toValue: 0,
duration: 5500,
chiragsalian marked this conversation as resolved.
Show resolved Hide resolved
useNativeDriver: false,
}).start();
});
}

/**
* Show the ReportActionContextMenu modal popover.
*
Expand Down Expand Up @@ -166,7 +209,7 @@ class ReportActionItem extends Component {
>
<Hoverable resetsOnClickOutside>
{hovered => (
<View>
<Animated.View style={this.animatedBackgroundStyle}>
{this.props.shouldDisplayNewIndicator && (
<UnreadActionIndicator />
)}
Expand Down Expand Up @@ -201,7 +244,7 @@ class ReportActionItem extends Component {
}
draftMessage={this.props.draftMessage}
/>
</View>
</Animated.View>
)}
</Hoverable>
<View style={styles.reportActionSystemMessageContainer}>
Expand Down
17 changes: 17 additions & 0 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const propTypes = {
hasOutstandingIOU: PropTypes.bool,
}).isRequired,

/** The reportActionID provided in the URL */
reportActionID: PropTypes.string.isRequired,

/** Should the reportActionID be highlighted */
shouldHighlightReportActionID: PropTypes.bool.isRequired,

/** Sorted actions prepared for display */
sortedReportActions: PropTypes.arrayOf(PropTypes.shape({
/** Index of the action in the array */
Expand All @@ -56,6 +62,12 @@ const propTypes = {
/** Callback executed on scroll */
onScroll: PropTypes.func.isRequired,

/** Callback for when the item is rendered */
onItemRendered: PropTypes.func.isRequired,

/** Callback for when measurement is done */
onMeasurementEnd: PropTypes.func.isRequired,

/** Function to load more chats */
loadMoreChats: PropTypes.func.isRequired,

Expand Down Expand Up @@ -115,6 +127,7 @@ class ReportActionsList extends React.Component {
renderItem({
item,
index,
shouldTrackItemRendered,
}) {
const shouldDisplayNewIndicator = this.props.report.newMarkerSequenceNumber > 0
&& item.action.sequenceNumber === this.props.report.newMarkerSequenceNumber;
Expand All @@ -127,6 +140,8 @@ class ReportActionsList extends React.Component {
isMostRecentIOUReportAction={item.action.sequenceNumber === this.props.mostRecentIOUReportSequenceNumber}
hasOutstandingIOU={this.props.report.hasOutstandingIOU}
index={index}
shouldHighlight={this.props.shouldHighlightReportActionID && this.props.reportActionID === item.action.reportActionID}
onItemRendered={shouldTrackItemRendered ? this.props.onItemRendered : () => {}}
/>
);
}
Expand Down Expand Up @@ -177,6 +192,8 @@ class ReportActionsList extends React.Component {
onLayout={this.props.onLayout}
onScroll={this.props.onScroll}
extraData={extraData}
measurementPadding={shouldShowReportRecipientLocalTime ? 0 : styles.chatContentScrollView.paddingVertical}
onMeasurementEnd={this.props.onMeasurementEnd}
/>
);
}
Expand Down
Loading