Skip to content

Commit

Permalink
Remove inner method and put its content in the place where is using t…
Browse files Browse the repository at this point in the history
…he removed method
  • Loading branch information
wlegolas committed Jan 11, 2024
1 parent 36f43ae commit 326f61d
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@ function getForDistanceRequest(newDistance: string, oldDistance: string, newAmou
});
}

/**
* Build message fragment for the created property when this value was changed
*/
function buildMessageFragmentForCreated(setFragments: string[], removalFragments: string[], changeFragments: string[], reportActionOriginalMessage?: ExpenseOriginalMessage) {
const {created, oldCreated} = reportActionOriginalMessage ?? {};

if (!oldCreated || !created) {
return;
}

// Take only the YYYY-MM-DD value as the original date includes timestamp
const formattedOldCreated = DateUtils.formatWithUTCTimeZone(oldCreated, CONST.DATE.FNS_FORMAT_STRING);

buildMessageFragmentForValue(created, formattedOldCreated, Localize.translateLocal('common.date'), false, setFragments, removalFragments, changeFragments);
}

/**
* Get the report action message when expense has been modified.
*
Expand Down Expand Up @@ -159,7 +143,19 @@ function getForReportAction(reportAction: ReportAction): string {
);
}

buildMessageFragmentForCreated(setFragments, removalFragments, changeFragments, reportActionOriginalMessage);
if (reportActionOriginalMessage?.oldCreated && reportActionOriginalMessage?.created) {
const formattedOldCreated = DateUtils.formatWithUTCTimeZone(reportActionOriginalMessage.oldCreated, CONST.DATE.FNS_FORMAT_STRING);

buildMessageFragmentForValue(
reportActionOriginalMessage.created,
formattedOldCreated,
Localize.translateLocal('common.date'),
false,
setFragments,
removalFragments,
changeFragments,
);
}

if (hasModifiedMerchant) {
buildMessageFragmentForValue(
Expand Down

0 comments on commit 326f61d

Please sign in to comment.