Skip to content

Commit

Permalink
Merge pull request #49482 from ishpaul777/fix/bad-grammar
Browse files Browse the repository at this point in the history
fixes optimistc case and delay submission current user bad grammar

(cherry picked from commit 5491db3)

(CP triggered by grgia)
  • Loading branch information
grgia authored and OSBotify committed Sep 19, 2024
1 parent 59bf97f commit 4e85c24
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
17 changes: 14 additions & 3 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -116,6 +121,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
{
text: `${ownerDisplayName}`,
type: 'strong',
clickToCopyText: ownerAccountID === currentUserAccountID ? currentUserEmail : '',
},
{
text: ' to ',
Expand All @@ -136,7 +142,12 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
text: 'Waiting for ',
},
{
text: `${ownerDisplayName}'s`,
text: `${ownerDisplayName}`,
type: 'strong',
clickToCopyText: ownerAccountID === currentUserAccountID ? currentUserEmail : '',
},
{
text: `'s`,
type: 'strong',
},
{
Expand Down
49 changes: 42 additions & 7 deletions tests/unit/NextStepUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -143,7 +148,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -173,7 +183,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -203,7 +218,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -234,7 +254,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -267,7 +292,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -298,7 +328,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down

0 comments on commit 4e85c24

Please sign in to comment.