Defers legacy mutation of object till after a creation happens. (#3379)

* Defers legacy mutation of object till after a creation happens.

* Fixes display layout to defer actions until objects.save returns

* Revert back to localStorage... big oops!
This commit is contained in:
Shefali Joshi
2020-09-17 13:53:45 -07:00
committed by GitHub
parent 67749dd2bb
commit 08b2940eb6
5 changed files with 53 additions and 37 deletions

View File

@@ -192,6 +192,7 @@ define([
*/
ObjectAPI.prototype.save = function (domainObject) {
let provider = this.getProvider(domainObject.identifier);
let savedResolve;
let result;
if (!this.isPersistable(domainObject)) {
@@ -200,8 +201,14 @@ define([
result = Promise.resolve(true);
} else {
if (domainObject.persisted === undefined) {
this.mutate(domainObject, 'persisted', domainObject.modified);
result = provider.create(domainObject);
domainObject.persisted = domainObject.modified;
result = new Promise((resolve) => {
savedResolve = resolve;
});
provider.create(domainObject).then((response) => {
this.mutate(domainObject, 'persisted', domainObject.modified);
savedResolve(response);
});
} else {
this.mutate(domainObject, 'persisted', domainObject.modified);
result = provider.update(domainObject);