From fd0f49fe4183fbdbb732b75b9a9a75a4b2fd98ee Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 29 Jun 2021 22:37:10 +0530 Subject: [PATCH 1/2] new: added drafts in GSD mode --- src/libs/OptionsListUtils.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 1b3666d56c64..4349d631c653 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -269,6 +269,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { searchValue = '', showChatPreviewLine = false, showReportsWithNoComments = false, + showReportsWithDrafts = false, hideReadReports = false, sortByAlphaAsc = false, forcePolicyNamePreview = false, @@ -296,10 +297,19 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { return; } + const hasDraftComment = report + && draftComments + && lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0; + + const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0; const shouldFilterReportIfRead = hideReadReports && report.unreadActionCount === 0; + const shouldShowReportIfhasDraft = showReportsWithDrafts && hasDraftComment; const shouldFilterReport = shouldFilterReportIfEmpty || shouldFilterReportIfRead; - if (report.reportID !== activeReportID && !report.isPinned && shouldFilterReport) { + if (report.reportID !== activeReportID + && !report.isPinned + && !shouldShowReportIfhasDraft + && shouldFilterReport) { return; } @@ -400,11 +410,11 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { let userToInvite = null; if (searchValue - && recentReportOptions.length === 0 - && personalDetailsOptions.length === 0 - && _.every(selectedOptions, option => option.login !== searchValue) - && ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue)) - && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) + && recentReportOptions.length === 0 + && personalDetailsOptions.length === 0 + && _.every(selectedOptions, option => option.login !== searchValue) + && ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue)) + && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) ) { // If the phone number doesn't have an international code then let's prefix it with the // current user's international code based on their IP address. @@ -561,6 +571,7 @@ function getSidebarOptions(reports, personalDetails, draftComments, activeReport sideBarOptions = { hideReadReports: true, sortByAlphaAsc: true, + showReportsWithDrafts: true, }; } From 775cecbf6b1c70a75718edd31673cb3239e72fa8 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 1 Jul 2021 09:07:06 +0530 Subject: [PATCH 2/2] refactor --- src/libs/OptionsListUtils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 4349d631c653..21130c3be2f8 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -301,14 +301,13 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { && draftComments && lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0; - const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0; const shouldFilterReportIfRead = hideReadReports && report.unreadActionCount === 0; - const shouldShowReportIfhasDraft = showReportsWithDrafts && hasDraftComment; + const shouldShowReportIfHasDraft = showReportsWithDrafts && hasDraftComment; const shouldFilterReport = shouldFilterReportIfEmpty || shouldFilterReportIfRead; if (report.reportID !== activeReportID && !report.isPinned - && !shouldShowReportIfhasDraft + && !shouldShowReportIfHasDraft && shouldFilterReport) { return; }