Skip to content

Commit

Permalink
Optimized listening to hasDraft property changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebryu committed Oct 20, 2023
1 parent 69cf29e commit 0fbc48e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/components/LHNOptionsList/OptionRowLHNData.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,10 @@ const personalDetailsSelector = (personalDetails) =>
*/
export default React.memo(
compose(
withReportCommentDrafts({
propName: 'comment',
transformValue: (drafts, props) => {
const draftKey = `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${props.reportID}`;
return lodashGet(drafts, draftKey, '');
},
}),
withOnyx({
comment: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
},
fullReport: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default compose(
},
parentReport: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || report.reportID}`,
selector: ({ hasDraft, ...report}={}) => report, // hasDraft not needed in this component
},
session: {
key: ONYXKEYS.SESSION,
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ export default compose(
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`,
allowStaleData: true,
selector: ({ hasDraft, ...report}={}) => report, // hasDraft not needed in this component
},
reportMetadata: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`,
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default compose(
withOnyx({
report: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
selector: ({ hasDraft, ...report}={}) => report, // hasDraft not needed in this component
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
Expand Down

0 comments on commit 0fbc48e

Please sign in to comment.