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

New: Added drafts in GSD / #focus mode #3793

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Changes from all commits
Commits
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
22 changes: 16 additions & 6 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
searchValue = '',
showChatPreviewLine = false,
showReportsWithNoComments = false,
showReportsWithDrafts = false,
hideReadReports = false,
sortByAlphaAsc = false,
forcePolicyNamePreview = false,
Expand Down Expand Up @@ -296,10 +297,18 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
return;
}

const hasDraftComment = report
&& draftComments
&& lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0;

parasharrajat marked this conversation as resolved.
Show resolved Hide resolved
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;
}

Expand Down Expand Up @@ -400,11 +409,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.
Expand Down Expand Up @@ -561,6 +570,7 @@ function getSidebarOptions(reports, personalDetails, draftComments, activeReport
sideBarOptions = {
hideReadReports: true,
sortByAlphaAsc: true,
showReportsWithDrafts: true,
};
}

Expand Down