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

Fix user cannot remove the description #20544

Merged
merged 6 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 5 additions & 6 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ROUTES from '../../ROUTES';
import CONST from '../../CONST';
import DateUtils from '../DateUtils';
import * as UserUtils from '../UserUtils';
import _ from 'underscore';

/**
* Clears out the task info from the store
Expand Down Expand Up @@ -278,14 +279,12 @@ function reopenTask(taskReportID, taskTitle) {
* @function editTask
* @param {object} report
* @param {string} ownerEmail
* @param {string} title
* @param {string} description
* @param {string} assignee
* @param {{title?: string, description?: string, assignee?:string}} editedTask
* @returns {object} action
*
*/

function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
function editTaskAndNavigate(report, ownerEmail, {title, description, assignee}) {
// Create the EditedReportAction on the task
const editTaskReportAction = ReportUtils.buildOptimisticEditedTaskReportAction(ownerEmail);

Expand Down Expand Up @@ -313,7 +312,7 @@ function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`,
value: {
reportName,
description: description.trim(),
description: (!_.isUndefined(description) ? description : report.description).trim(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 Can we follow DRY code here , should be extracted at the top below line 292

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh I updated.

managerEmail: assignee || report.managerEmail,
},
},
Expand Down Expand Up @@ -368,7 +367,7 @@ function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
{
taskReportID: report.reportID,
title: reportName,
description: (description || report.description).trim(),
description: (!_.isUndefined(description) ? description : report.description).trim(),
assignee: assignee || report.managerEmail,
editedTaskReportActionID: editTaskReportAction.reportActionID,
assigneeChatReportActionID: optimisticAssigneeAddComment ? optimisticAssigneeAddComment.reportAction.reportActionID : 0,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const TaskAssigneeSelectorModal = (props) => {
// This would cause the app to crash, so we need to make sure we have a DM thread
TaskUtils.setAssigneeValue(option.login, props.task.shareDestination, OptionsListUtils.isCurrentUser(option));
// Pass through the selected assignee
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, '', '', option.login);
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {assignee: option.login});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function TaskDescriptionPage(props) {
(values) => {
// Set the description of the report in the store and then call TaskUtils.editTaskReport
// to update the description of the report on the server
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, '', values.description, '');
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {description: values.description});
},
[props],
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskTitlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function TaskTitlePage(props) {
// Set the description of the report in the store and then call TaskUtils.editTaskReport
// to update the description of the report on the server

TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, values.title, '', '');
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {title: values.title});
},
[props],
);
Expand Down