Only persist latest mutated model. (#2295)

* Only persist latest mutated model. Fixes #2277

* Updated tests

* Fixed style issues
This commit is contained in:
Andrew Henry
2019-02-22 13:45:44 -08:00
committed by Deep Tailor
parent a8ba3b3fdb
commit 98c8e19d93
4 changed files with 52 additions and 65 deletions

View File

@@ -43,20 +43,10 @@ define([], function () {
var mutationTopic = topic('mutation');
mutationTopic.listen(function (domainObject) {
var persistence = domainObject.getCapability('persistence');
var wasActive = transactionService.isActive();
cacheService.put(domainObject.getId(), domainObject.getModel());
if (hasChanged(domainObject)) {
if (!wasActive) {
transactionService.startTransaction();
}
persistence.persist();
if (!wasActive) {
transactionService.commit();
}
}
});
}