Skip to content

Commit 132199c

Browse files
committed
Merge remote-tracking branch 'upstream/main'
merge
2 parents 3d2086a + ef3d8cd commit 132199c

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

src/libs/StringUtils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,13 @@ function removeInvisibleCharacters(value: string): string {
6363
return result.trim();
6464
}
6565

66-
export default {sanitizeString, isEmptyString, removeInvisibleCharacters};
66+
/**
67+
* Replace all CRLF with LF
68+
* @param value - The input string
69+
* @returns The string with all CRLF replaced with LF
70+
*/
71+
function normalizeCRLF(value?: string): string | undefined {
72+
return value?.replace(/\r\n/g, '\n');
73+
}
74+
75+
export default {sanitizeString, isEmptyString, removeInvisibleCharacters, normalizeCRLF};

src/libs/actions/Task.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function reopenTask(taskReport) {
366366
* @param {object} report
367367
* @param {Object} editedTask
368368
*/
369-
function editTaskAndNavigate(report, {title, description}) {
369+
function editTask(report, {title, description}) {
370370
// Create the EditedReportAction on the task
371371
const editTaskReportAction = ReportUtils.buildOptimisticEditedTaskReportAction(currentUserEmail);
372372

@@ -433,11 +433,9 @@ function editTaskAndNavigate(report, {title, description}) {
433433
},
434434
{optimisticData, successData, failureData},
435435
);
436-
437-
Navigation.dismissModal(report.reportID);
438436
}
439437

440-
function editTaskAssigneeAndNavigate(report, ownerAccountID, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null) {
438+
function editTaskAssignee(report, ownerAccountID, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null) {
441439
// Create the EditedReportAction on the task
442440
const editTaskReportAction = ReportUtils.buildOptimisticEditedTaskReportAction(currentUserEmail);
443441
const reportName = report.reportName.trim();
@@ -525,8 +523,6 @@ function editTaskAssigneeAndNavigate(report, ownerAccountID, assigneeEmail, assi
525523
},
526524
{optimisticData, successData, failureData},
527525
);
528-
529-
Navigation.dismissModal(report.reportID);
530526
}
531527

532528
/**
@@ -628,9 +624,9 @@ function setAssigneeValue(assigneeEmail, assigneeAccountID, shareDestination, is
628624
// This is only needed for creation of a new task and so it should only be stored locally
629625
Onyx.merge(ONYXKEYS.TASK, {assignee: assigneeEmail, assigneeAccountID});
630626

631-
// When we're editing the assignee, we immediately call EditTaskAndNavigate. Since setting the assignee is async,
632-
// the chatReport is not yet set when EditTaskAndNavigate is called. So we return the chatReport here so that
633-
// EditTaskAndNavigate can use it.
627+
// When we're editing the assignee, we immediately call editTaskAssignee. Since setting the assignee is async,
628+
// the chatReport is not yet set when editTaskAssignee is called. So we return the chatReport here so that
629+
// editTaskAssignee can use it.
634630
return chatReport;
635631
}
636632

@@ -941,8 +937,8 @@ function getTaskReportActionMessage(actionName, reportID, isCreateTaskAction) {
941937

942938
export {
943939
createTaskAndNavigate,
944-
editTaskAndNavigate,
945-
editTaskAssigneeAndNavigate,
940+
editTask,
941+
editTaskAssignee,
946942
setTitleValue,
947943
setDescriptionValue,
948944
setTaskReport,

src/pages/tasks/TaskAssigneeSelectorModal.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,13 @@ function TaskAssigneeSelectorModal(props) {
196196

197197
// Check to see if we're editing a task and if so, update the assignee
198198
if (report) {
199-
const assigneeChatReport = Task.setAssigneeValue(option.login, option.accountID, props.route.params.reportID, OptionsListUtils.isCurrentUser(option));
199+
if (option.accountID !== report.managerID) {
200+
const assigneeChatReport = Task.setAssigneeValue(option.login, option.accountID, props.route.params.reportID, OptionsListUtils.isCurrentUser(option));
200201

201-
// Pass through the selected assignee
202-
Task.editTaskAssigneeAndNavigate(report, props.session.accountID, option.login, option.accountID, assigneeChatReport);
202+
// Pass through the selected assignee
203+
Task.editTaskAssignee(report, props.session.accountID, option.login, option.accountID, assigneeChatReport);
204+
}
205+
return Navigation.dismissModal(report.reportID);
203206
}
204207
};
205208

src/pages/tasks/TaskDescriptionPage.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as Browser from '@libs/Browser';
1515
import compose from '@libs/compose';
1616
import Navigation from '@libs/Navigation/Navigation';
1717
import * as ReportUtils from '@libs/ReportUtils';
18+
import StringUtils from '@libs/StringUtils';
1819
import updateMultilineInputRange from '@libs/UpdateMultilineInputRange';
1920
import withReportOrNotFound from '@pages/home/report/withReportOrNotFound';
2021
import reportPropTypes from '@pages/reportPropTypes';
@@ -42,9 +43,14 @@ function TaskDescriptionPage(props) {
4243

4344
const submit = useCallback(
4445
(values) => {
45-
// Set the description of the report in the store and then call Task.editTaskReport
46-
// to update the description of the report on the server
47-
Task.editTaskAndNavigate(props.report, {description: values.description});
46+
// props.report.description might contain CRLF from the server
47+
if (StringUtils.normalizeCRLF(values.description) !== StringUtils.normalizeCRLF(props.report.description)) {
48+
// Set the description of the report in the store and then call EditTask API
49+
// to update the description of the report on the server
50+
Task.editTask(props.report, {description: values.description});
51+
}
52+
53+
Navigation.dismissModal(props.report.reportID);
4854
},
4955
[props],
5056
);

src/pages/tasks/TaskTitlePage.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ function TaskTitlePage(props) {
5151

5252
const submit = useCallback(
5353
(values) => {
54-
// Set the title of the report in the store and then call Task.editTaskReport
55-
// to update the title of the report on the server
56-
Task.editTaskAndNavigate(props.report, {title: values.title});
54+
if (values.title !== props.report.reportName) {
55+
// Set the title of the report in the store and then call EditTask API
56+
// to update the title of the report on the server
57+
Task.editTask(props.report, {title: values.title});
58+
}
59+
60+
Navigation.dismissModal(props.report.reportID);
5761
},
5862
[props],
5963
);

0 commit comments

Comments
 (0)