Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse the task description when saving it #40625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4539,7 +4539,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
Loading