Skip to content

Commit

Permalink
fix for possible race condition in setting edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nbarlowATI committed Apr 25, 2022
1 parent 48e0bc5 commit 988f39f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions frontend/src/components/CaseContainer.js
Expand Up @@ -66,7 +66,7 @@ class CaseContainer extends Component {
headers: { "Content-Type": "application/json" },
body: JSON.stringify(changeObj),
};
fetch(backendURL, requestOptions);
return fetch(backendURL, requestOptions);
}

deleteCurrentCase() {
Expand Down Expand Up @@ -158,7 +158,7 @@ class CaseContainer extends Component {
this.hideViewLayer();
this.hideEditLayer();
this.hideCreateLayer();
this.fetchData(this.state.id);
return this.fetchData(this.state.id);
}

showViewLayer(e) {
Expand Down Expand Up @@ -372,25 +372,33 @@ class CaseContainer extends Component {

enableEditing() {
if (!this.state.assurance_case.lock_uuid) {
this.submitCaseChange("lock_uuid", this.state.session_id);
this.submitCaseChange("lock_uuid", this.state.session_id).then(
(response) => {
this.updateView();
}
);
} else if (this.state.assurance_case.lock_uuid !== this.state.session_id) {
// override!
if (
window.confirm(
"Are you sure? You might be overwriting someone's work..."
)
) {
this.submitCaseChange("lock_uuid", this.state.session_id);
this.submitCaseChange("lock_uuid", this.state.session_id).then(
(response) => {
this.updateView();
}
);
}
}
this.updateView();
}

disableEditing() {
if (this.state.assurance_case.lock_uuid) {
this.submitCaseChange("lock_uuid", null);
this.submitCaseChange("lock_uuid", null).then((response) => {
this.updateView();
});
}
this.updateView();
}

inEditMode() {
Expand Down

0 comments on commit 988f39f

Please sign in to comment.