-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
14893: Edit message arrow up #15207
14893: Edit message arrow up #15207
Changes from 6 commits
4ef5645
0c821ff
0d1f768
0d91a37
17dc211
f54539a
6091178
e1834f1
5ec7c39
8114e7d
112ce8a
8118c20
9444c98
2b1a943
42ce483
6784b28
ab82acd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ const propTypes = { | |
report: reportPropTypes.isRequired, | ||
|
||
/** Array of report actions for this report */ | ||
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), | ||
reportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)), | ||
|
||
/** The session of the logged in person */ | ||
session: PropTypes.shape({ | ||
|
@@ -49,7 +49,7 @@ const propTypes = { | |
}; | ||
|
||
const defaultProps = { | ||
reportActions: {}, | ||
reportActions: [], | ||
luacmartins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
session: {}, | ||
}; | ||
|
||
|
@@ -62,12 +62,9 @@ class ReportActionsView extends React.Component { | |
this.unsubscribeVisibilityListener = null; | ||
this.hasCachedActions = _.size(props.reportActions) > 0; | ||
|
||
// We need this.sortedAndFilteredReportActions to be set before this.state is initialized because the function to calculate the newMarkerReportActionID uses the sorted report actions | ||
this.sortedAndFilteredReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(props.reportActions); | ||
|
||
this.state = { | ||
isFloatingMessageCounterVisible: false, | ||
newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, this.sortedAndFilteredReportActions), | ||
newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, props.reportActions), | ||
}; | ||
|
||
this.currentScrollOffset = 0; | ||
|
@@ -130,56 +127,6 @@ class ReportActionsView extends React.Component { | |
}); | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
if (!_.isEqual(nextProps.reportActions, this.props.reportActions)) { | ||
this.sortedAndFilteredReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(nextProps.reportActions); | ||
this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOUReportActionID(nextProps.reportActions); | ||
return true; | ||
} | ||
|
||
if (lodashGet(nextProps.network, 'isOffline') !== lodashGet(this.props.network, 'isOffline')) { | ||
return true; | ||
} | ||
|
||
if (nextProps.report.isLoadingMoreReportActions !== this.props.report.isLoadingMoreReportActions) { | ||
return true; | ||
} | ||
|
||
if (nextProps.report.isLoadingReportActions !== this.props.report.isLoadingReportActions) { | ||
return true; | ||
} | ||
|
||
if (nextProps.report.lastReadTime !== this.props.report.lastReadTime) { | ||
return true; | ||
} | ||
|
||
if (nextState.isFloatingMessageCounterVisible !== this.state.isFloatingMessageCounterVisible) { | ||
return true; | ||
} | ||
|
||
if (nextState.newMarkerReportActionID !== this.state.newMarkerReportActionID) { | ||
return true; | ||
} | ||
|
||
if (this.props.isSmallScreenWidth !== nextProps.isSmallScreenWidth) { | ||
return true; | ||
} | ||
|
||
if (this.props.isDrawerOpen !== nextProps.isDrawerOpen) { | ||
return true; | ||
} | ||
|
||
if (lodashGet(this.props.report, 'hasOutstandingIOU') !== lodashGet(nextProps.report, 'hasOutstandingIOU')) { | ||
return true; | ||
} | ||
|
||
if (this.props.isComposerFullSize !== nextProps.isComposerFullSize) { | ||
return true; | ||
} | ||
|
||
return !_.isEqual(lodashGet(this.props.report, 'icons', []), lodashGet(nextProps.report, 'icons', [])); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
const isReportFullyVisible = this.getIsReportFullyVisible(); | ||
|
||
|
@@ -203,16 +150,17 @@ class ReportActionsView extends React.Component { | |
if (didReportBecomeVisible) { | ||
this.setState({ | ||
newMarkerReportActionID: ReportUtils.isUnread(this.props.report) | ||
? ReportUtils.getNewMarkerReportActionID(this.props.report, this.sortedAndFilteredReportActions) | ||
? ReportUtils.getNewMarkerReportActionID(this.props.report, this.props.reportActions) | ||
: '', | ||
}); | ||
this.openReportIfNecessary(); | ||
} | ||
|
||
// If the report action marking the unread point is deleted we need to recalculate which action should be the unread marker | ||
if (this.state.newMarkerReportActionID && _.isEmpty(lodashGet(this.props.reportActions[this.state.newMarkerReportActionID], 'message[0].html'))) { | ||
// If the report is unread, we want to check if the number of actions has decreased. If so, then it seems that one of them was deleted. In this case, if the deleted action was the | ||
// one marking the unread point, we need to recalculate which action should be the unread marker. | ||
if (ReportUtils.isUnread(this.props.report) && ReportActionsUtils.filterReportActionsForDisplay(prevProps.reportActions).length > this.props.reportActions.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was removed here c351930 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will look at it thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, please remove here as well. App crashes right now when other sends message which makes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, cool, I will update it |
||
this.setState({ | ||
newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, this.sortedAndFilteredReportActions), | ||
newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, this.props.reportActions), | ||
}); | ||
} | ||
|
||
|
@@ -229,7 +177,7 @@ class ReportActionsView extends React.Component { | |
const didManuallyMarkReportAsUnread = (prevProps.report.lastReadTime !== this.props.report.lastReadTime) | ||
&& ReportUtils.isUnread(this.props.report); | ||
if (didManuallyMarkReportAsUnread) { | ||
this.setState({newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, this.sortedAndFilteredReportActions)}); | ||
this.setState({newMarkerReportActionID: ReportUtils.getNewMarkerReportActionID(this.props.report, this.props.reportActions)}); | ||
} | ||
|
||
// Ensures subscription event succeeds when the report/workspace room is created optimistically. | ||
|
@@ -283,7 +231,7 @@ class ReportActionsView extends React.Component { | |
return; | ||
} | ||
|
||
const oldestReportAction = _.last(this.sortedAndFilteredReportActions); | ||
const oldestReportAction = _.last(this.props.reportActions); | ||
|
||
// Don't load more chats if we're already at the beginning of the chat history | ||
if (oldestReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { | ||
|
@@ -347,7 +295,6 @@ class ReportActionsView extends React.Component { | |
if (!_.size(this.props.reportActions)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{!this.props.isComposerFullSize && ( | ||
|
@@ -360,7 +307,7 @@ class ReportActionsView extends React.Component { | |
report={this.props.report} | ||
onScroll={this.trackScroll} | ||
onLayout={this.recordTimeToMeasureItemLayout} | ||
sortedReportActions={this.sortedAndFilteredReportActions} | ||
sortedReportActions={this.props.reportActions} | ||
mostRecentIOUReportActionID={this.mostRecentIOUReportActionID} | ||
isLoadingMoreReportActions={this.props.report.isLoadingMoreReportActions} | ||
loadMoreChats={this.loadMoreChats} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we return true if
this.props.report
changed?I found regression (not refreshing) while adding/removing members.
i.e.
-This should not show Split bill on + menu.
This works fine on production
This happens because
report.participants
updated but not re-renderedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am asking this because this already does in
main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xmiroslav so this is not a regression from this PR? I think if not, we can continue here and you can file a bug report for this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR causes that regression.
Here,
does
meansre-renders
becauseReportScreen
doesn't either extendPureComponent
or useshouldComponentUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I don't think we need
shouldComponentUpdate
inReportScreen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gedu For what optimization did you introduce
shouldComponentUpdate
inReportScreen
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xmiroslav Hey, I've been looking at what you wrote and couldn't reproduce it like that, I could, following other steps, and only on web, mobile is working as expected.
Screen.Recording.2023-02-27.at.09.28.55.mp4
On the other hand, looking at the code, I see
#announce
and#admins
always will show Split Bill on the + menu (if there are 2 members). This was working (above in the video showing the only case isn't working).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the check to the reports as you suggested and is fixing the case I found, doing some round of testing and uploading fix, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gedu you opened production site on left. please run this PR on both sides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed it here and we determined that it's ok to filter/sort in
render()
. I think that we should do that and remove the derived state.