Skip to content

Commit

Permalink
Use local variable isChatRoom instead of referencing twice
Browse files Browse the repository at this point in the history
  • Loading branch information
sobitneupane committed Feb 1, 2022
1 parent 5e7299c commit 88250fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,15 @@ function configureReportNameAndIcons(reports, details) {
if (report.participants.length <= 0 && !ReportUtils.isChatRoom(report)) {
return;
}
const isChatRoom = ReportUtils.isChatRoom(report);

const avatars = ReportUtils.isChatRoom(report) ? (['']) : OptionsListUtils.getReportIcons(report, details);
const reportName = ReportUtils.isChatRoom(report)
// Chat rooms have a specific avatar so we can return any non-empty array but for 1:1 chats and group chats
// avatars are extracted from avatars of the participants.
const avatars = isChatRoom ? (['']) : OptionsListUtils.getReportIcons(report, details);

// ReportName is already present in report for chatrooms but for 1:1 chats and group chats
// reportName is extracted from displayNames of the participants.
const reportName = isChatRoom
? report.reportName
: _.chain(report.participants)
.filter(participant => participant !== currentUserEmail)
Expand Down

0 comments on commit 88250fb

Please sign in to comment.