From 63893feb7cfb17678540fe8321b544d9218e2621 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 7 Aug 2024 21:50:51 +0700 Subject: [PATCH] fix: Sending a text+attachment displays text with ellipsis --- src/libs/SidebarUtils.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index ceb10be6a634..bc054311e93f 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -405,7 +405,7 @@ function getOptionData({ ? Localize.translate(preferredLocale, 'workspace.invite.invited') : Localize.translate(preferredLocale, 'workspace.invite.removed'); const users = Localize.translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); - result.alternateText = `${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`.trim(); + result.alternateText = ReportUtils.formatReportLastMessageText(`${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`); const roomName = lastActionOriginalMessage?.roomName ?? ''; if (roomName) { @@ -413,18 +413,21 @@ function getOptionData({ lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? ` ${Localize.translate(preferredLocale, 'workspace.invite.to')}` : ` ${Localize.translate(preferredLocale, 'workspace.invite.from')}`; - result.alternateText += `${preposition} ${roomName}`; + result.alternateText += ReportUtils.formatReportLastMessageText(`${preposition} ${roomName}`); } } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { - result.alternateText = `${lastActorDisplayName}: ${lastMessageText}`; + result.alternateText = ReportUtils.formatReportLastMessageText(`${lastActorDisplayName}: ${lastMessageText}`); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) { result.alternateText = PolicyUtils.getCleanedTagName(ReportActionsUtils.getReportActionMessage(lastAction)?.text ?? ''); } else { - result.alternateText = lastMessageTextFromReport.length > 0 ? lastMessageText : ReportActionsUtils.getLastVisibleMessage(report.reportID, {}, lastAction)?.lastMessageText; + result.alternateText = + lastMessageTextFromReport.length > 0 + ? ReportUtils.formatReportLastMessageText(lastMessageText) + : ReportActionsUtils.getLastVisibleMessage(report.reportID, {}, lastAction)?.lastMessageText; if (!result.alternateText) { result.alternateText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? Localize.translateLocal('report.noActivityYet')); } @@ -436,8 +439,8 @@ function getOptionData({ result.alternateText = (ReportUtils.isGroupChat(report) || ReportUtils.isDeprecatedGroupDM(report)) && lastActorDisplayName - ? `${lastActorDisplayName}: ${lastMessageText}` - : lastMessageText || formattedLogin; + ? ReportUtils.formatReportLastMessageText(`${lastActorDisplayName}: ${lastMessageText}`) + : ReportUtils.formatReportLastMessageText(lastMessageText) || formattedLogin; } result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report);