Bring across fixes for #1468 and #2277 into TCR (#2386)

This commit is contained in:
Andrew Henry
2019-04-24 16:01:45 -07:00
committed by Pegah Sarram
parent f01d4071a1
commit d2e2d55caf
4 changed files with 69 additions and 78 deletions

View File

@@ -43,23 +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();
}
transactionService.addToTransaction(
persistence.persist.bind(persistence),
persistence.refresh.bind(persistence)
);
if (!wasActive) {
transactionService.commit();
}
persistence.persist();
}
});
}