-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix/33760 doubled display name on search page #33966
Merged
mountiny
merged 7 commits into
Expensify:main
from
koko57:fix/33760-doubled-displayName-on-searchPage
Jan 9, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
16b3280
fix: remove doubled name for IOUs previews in SearchPage
koko57 2a924ae
fix: resolve conflicts
koko57 6eff84d
Merge branch 'main' into fix/33760-doubled-displayName-on-searchPage
koko57 11e24a3
fix: restore getDisplayNameOrDefault
koko57 a3f2abc
Merge branch 'main' into fix/33760-doubled-displayName-on-searchPage
koko57 37e83cd
fix: display actor name for threads
koko57 4b985db
fix: run prettier
koko57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -72,6 +72,7 @@ Onyx.connect({ | |||||
const lastReportActions = {}; | ||||||
const allSortedReportActions = {}; | ||||||
const allReportActions = {}; | ||||||
const visibleReportActionItems = {}; | ||||||
Onyx.connect({ | ||||||
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||||||
callback: (actions, key) => { | ||||||
|
@@ -83,6 +84,18 @@ Onyx.connect({ | |||||
const sortedReportActions = ReportActionUtils.getSortedReportActions(_.toArray(actions), true); | ||||||
allSortedReportActions[reportID] = sortedReportActions; | ||||||
lastReportActions[reportID] = _.first(sortedReportActions); | ||||||
|
||||||
// The report is only visible if it is the last action not deleted that | ||||||
// does not match a closed or created state. | ||||||
const reportActionsForDisplay = _.filter( | ||||||
sortedReportActions, | ||||||
(reportAction, actionKey) => | ||||||
ReportActionUtils.shouldReportActionBeVisible(reportAction, actionKey) && | ||||||
!ReportActionUtils.isWhisperAction(reportAction) && | ||||||
reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED && | ||||||
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, | ||||||
); | ||||||
visibleReportActionItems[reportID] = reportActionsForDisplay[reportActionsForDisplay.length - 1]; | ||||||
}, | ||||||
}); | ||||||
|
||||||
|
@@ -519,7 +532,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { | |||||
hasMultipleParticipants && lastActorDetails && lastActorDetails.accountID !== currentUserAccountID | ||||||
? lastActorDetails.firstName || PersonalDetailsUtils.getDisplayNameOrDefault(lastActorDetails) | ||||||
: ''; | ||||||
let lastMessageText = lastActorDisplayName ? `${lastActorDisplayName}: ${lastMessageTextFromReport}` : lastMessageTextFromReport; | ||||||
let lastMessageText = lastMessageTextFromReport; | ||||||
mountiny marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
if (result.isArchivedRoom) { | ||||||
const archiveReason = | ||||||
|
@@ -531,6 +544,13 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { | |||||
}); | ||||||
} | ||||||
|
||||||
const lastAction = visibleReportActionItems[report.reportID]; | ||||||
const shouldDisplayLastActorName = lastAction && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU; | ||||||
|
||||||
if (shouldDisplayLastActorName && lastActorDisplayName && lastMessageTextFromReport) { | ||||||
lastMessageText = `${lastActorDisplayName}: ${lastMessageTextFromReport}`; | ||||||
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. Let's define util function whether to add prefix or not and use it in both here and SidebarUtils Lines 401 to 402 in 3ee24ec
We should make |
||||||
} | ||||||
|
||||||
if (result.isThread || result.isMoneyRequestReport) { | ||||||
result.alternateText = lastMessageTextFromReport.length > 0 ? lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet'); | ||||||
} else if (result.isChatRoom || result.isPolicyExpenseChat) { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 code is also duplicated with SidebarUtils.
Let's try to avoid duplication as much as possible
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.
yes, but I think that the whole code for generating could be extracted to a separate function - we would not need a separate function for getting lastActorDisplayName then. I even wanted to do this in this PR, but it's a lot of changes, so I wanted to fix the issue this way, then take care of this refactor in a follow-up. Let me know what you think about that cc @mountiny
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.
In this case I agree to handle this in a follow up PR to get the fix in and limit chances of regressions. Will you handle the follow up @koko57 ?
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.
yeah, of course! 😊