Skip to content

Commit 19d1cff

Browse files
committed
add comment, checkUniqueness
1 parent 0447ac1 commit 19d1cff

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: platform/wab/src/wab/client/components/cms/CmsEntryDetails.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ function CmsEntryDetailsForm_(
356356

357357
async function checkUniqueness() {
358358
setCheckingUniqueness(true);
359-
let changedUniqueFields = {};
359+
const changedUniqueFields = {};
360+
/* The field is changed to "pending" before the request.
361+
If the user changes the field value before the response,
362+
the status is changed to "not started," and the previous result is ignored. */
360363
setUniqueFieldStatus((prev) => {
361364
const copy = { ...prev };
362365
Object.entries(copy).map(([fieldIdentifier, fieldStatus]) => {
363366
if (fieldStatus.status === "not started") {
364-
changedUniqueFields = {
365-
...changedUniqueFields,
366-
[fieldIdentifier]: fieldStatus.value,
367-
};
367+
changedUniqueFields[fieldIdentifier] = fieldStatus.value;
368368
fieldStatus.status = "pending";
369369
}
370370
});
@@ -378,11 +378,11 @@ function CmsEntryDetailsForm_(
378378
);
379379
setUniqueFieldStatus((prev) => {
380380
const copy = { ...prev };
381-
uniqueFieldsCheck.forEach((uniqueFieldCheck) => {
382-
const field = copy[uniqueFieldCheck.fieldIdentifier];
383-
if (field.status === "pending") {
384-
field.status = uniqueFieldCheck.ok ? "ok" : "violation";
385-
field.conflictEntryIds = uniqueFieldCheck.conflictRowIds;
381+
uniqueFieldsCheck.forEach((uniqueCheck) => {
382+
const identifier = uniqueCheck.fieldIdentifier;
383+
if (copy[identifier].status === "pending") {
384+
copy[identifier].status = uniqueCheck.ok ? "ok" : "violation";
385+
copy[identifier].conflictEntryIds = uniqueCheck.conflictRowIds;
386386
}
387387
});
388388
return copy;

0 commit comments

Comments
 (0)