From 4e85c2499a79ba264d99904de83a1ef760a0d0e9 Mon Sep 17 00:00:00 2001 From: Georgia Monahan <38015950+grgia@users.noreply.github.com> Date: Thu, 19 Sep 2024 21:16:44 +0100 Subject: [PATCH] Merge pull request #49482 from ishpaul777/fix/bad-grammar fixes optimistc case and delay submission current user bad grammar (cherry picked from commit 5491db314fe74952efc9bf34a453b3d76668d6e3) (CP triggered by grgia) --- src/libs/NextStepUtils.ts | 17 ++++++++++-- tests/unit/NextStepUtilsTest.ts | 49 ++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 6dc12d6d1211..7f13e1297b6f 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -38,14 +38,19 @@ Onyx.connect({ function parseMessage(messages: Message[] | undefined) { let nextStepHTML = ''; - messages?.forEach((part) => { + messages?.forEach((part, index) => { const isEmail = Str.isValidEmail(part.text); let tagType = part.type ?? 'span'; let content = Str.safeEscape(part.text); + const previousPart = messages[index - 1]; + const nextPart = messages[index + 1]; + if (currentUserEmail === part.text || part.clickToCopyText === currentUserEmail) { tagType = 'strong'; - content = 'You'; + content = nextPart?.text === `'s` ? 'Your' : 'You'; + } else if (part.text === `'s` && (previousPart?.text === currentUserEmail || previousPart?.clickToCopyText === currentUserEmail)) { + content = ''; } else if (isEmail) { tagType = 'next-step-email'; content = EmailUtils.prefixMailSeparatorsWithBreakOpportunities(content); @@ -116,6 +121,7 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -143,7 +148,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -173,7 +183,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -203,7 +218,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -234,7 +254,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -267,7 +292,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, { @@ -298,7 +328,12 @@ describe('libs/NextStepUtils', () => { text: 'Waiting for ', }, { - text: `${currentUserEmail}'s`, + text: `${currentUserEmail}`, + clickToCopyText: `${currentUserEmail}`, + type: 'strong', + }, + { + text: "'s", type: 'strong', }, {