-
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 copy invite room message #30898
Fix copy invite room message #30898
Changes from 1 commit
9fbb883
c1ddbef
427be61
4df098e
db16de3
65c5cc9
d581ca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4118,26 +4118,31 @@ function getIOUReportActionDisplayMessage(reportAction) { | |
|
||
/** | ||
* Return room channel log display message | ||
* | ||
* @param {Object} reportAction | ||
* @returns {String} | ||
*/ | ||
function getRoomChannelLogMemberMessage(reportAction) { | ||
const actionPerformed = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM ? 'invited' : 'removed'; | ||
const listMention = _.map(reportAction.originalMessage.targetAccountIDs, (accountID) => { | ||
|
||
const mentions = _.map(reportAction.originalMessage.targetAccountIDs, (accountID) => { | ||
const personalDetail = lodashGet(allPersonalDetails, accountID); | ||
const displayNameOrLogin = | ||
LocalePhoneNumber.formatPhoneNumber(lodashGet(personalDetail, 'login', '')) || lodashGet(personalDetail, 'displayName', '') || Localize.translateLocal('common.hidden'); | ||
return `@${displayNameOrLogin}`; | ||
}); | ||
const lastMention = listMention.pop(); | ||
let lastPrefix = ', and '; | ||
if (listMention.length === 0) { | ||
lastPrefix = ''; | ||
|
||
const lastMention = mentions.pop(); | ||
|
||
if (mentions.length === 0) { | ||
return `${actionPerformed} ${lastMention}`; | ||
} | ||
if (listMention.length === 1) { | ||
lastPrefix = ' and '; | ||
|
||
if (mentions.length === 1) { | ||
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. Have you actually tested that this case is required? I thought I tested it with my suggested variant 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. Oh... I think I get it 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. Still, I think this logic is still slightly more readable (even if the advantage is smaller than I originally assumed) |
||
return `${actionPerformed} ${mentions[0]} and ${lastMention}`; | ||
} | ||
return `${actionPerformed} ${listMention.join(', ')}${lastPrefix}${lastMention}`; | ||
|
||
return `${actionPerformed} ${mentions.join(', ')}, and ${lastMention}`; | ||
} | ||
|
||
/** | ||
|
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.
Looks better! But I have a suggestion to increase the simplicity of the function. Let me know if you agree.
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.
Look good to me. Will update soon.
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.
@cubuspl42 I updated.