Skip to content

Commit

Permalink
Merge pull request #40625 from bernhardoj/fix/39496-parse-task-descri…
Browse files Browse the repository at this point in the history
…ption

Parse the task description when saving it
  • Loading branch information
cristipaval authored May 13, 2024
2 parents 7b00564 + 1d860cc commit cf14505
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/components/ReportActionItem/TaskAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function TaskAction({action}: TaskActionProps) {

return (
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.breakWord, styles.preWrap]}>
{message.html ? <RenderHTML html={`<muted-text>${message.html}</muted-text>`} /> : <Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text>}
{message.html ? (
<RenderHTML html={`<comment><muted-text>${message.html}</muted-text></comment>`} />
) : (
<Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text>
)}
</View>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function TaskView({report, ...props}: TaskViewProps) {
</Hoverable>
<OfflineWithFeedback pendingAction={report.pendingFields?.description}>
<MenuItemWithTopDescription
shouldParseTitle
shouldRenderAsHTML
description={translate('task.description')}
title={report.description ?? ''}
onPress={() => Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID))}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4545,7 +4545,7 @@ function buildOptimisticEditedTaskFieldReportAction({title, description}: Task):
{
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
text: changelog,
html: changelog,
html: description ? getParsedComment(changelog) : changelog,
},
],
person: [
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task
const reportName = (title ?? report?.reportName)?.trim();

// Description can be unset, so we default to an empty string if so
const reportDescription = (description ?? report.description ?? '').trim();
const reportDescription = ReportUtils.getParsedComment((description ?? report.description ?? '').trim());

const optimisticData: OnyxUpdate[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/pages/tasks/TaskDescriptionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti

const submit = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_TASK_FORM>) => {
if (parser.htmlToMarkdown(parser.replace(values.description)) !== parser.htmlToMarkdown(parser.replace(report?.description ?? '')) && !isEmptyObject(report)) {
if (values.description !== parser.htmlToMarkdown(report?.description ?? '') && !isEmptyObject(report)) {
// Set the description of the report in the store and then call EditTask API
// to update the description of the report on the server
Task.editTask(report, {description: values.description});
Expand Down Expand Up @@ -110,7 +110,7 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti
name={INPUT_IDS.DESCRIPTION}
label={translate('newTaskPage.descriptionOptional')}
accessibilityLabel={translate('newTaskPage.descriptionOptional')}
defaultValue={parser.htmlToMarkdown((report && parser.replace(report?.description ?? '')) || '')}
defaultValue={parser.htmlToMarkdown(report?.description ?? '')}
ref={(element: AnimatedTextInputRef) => {
if (!element) {
return;
Expand Down

0 comments on commit cf14505

Please sign in to comment.