-rw-r--r-- | frontend/beta/js/Clipperz/PM/Connection.js | 9 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 12 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/User.js | 17 |
3 files changed, 24 insertions, 14 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Connection.js b/frontend/beta/js/Clipperz/PM/Connection.js index 85aea21..e81c7a6 100644 --- a/frontend/beta/js/Clipperz/PM/Connection.js +++ b/frontend/beta/js/Clipperz/PM/Connection.js @@ -298,3 +298,6 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']); - this.user().setLock(someParameters['lock']); + + if ((isReconnecting == true) && (this.user().lock() != someParameters['lock'])) { + throw Clipperz.PM.Connection.exception.StaleData; + } @@ -303,2 +306,3 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log } + result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn'); @@ -579,3 +583,4 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. Clipperz.PM.Connection.exception = { - WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue") + WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), + StaleData: new MochiKit.Base.NamedError("Stale data") }; diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index ffb45de..ecb6c37 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js @@ -641,7 +641,9 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam - if (this.isBrandNew() == false) { - result = this.user().saveRecords([this], 'updateData'); - } else { - result = this.user().saveRecords([this], 'addNewRecords'); - } +// if (this.isBrandNew() == false) { +// result = this.user().saveRecords([this], 'updateData'); +// } else { +// result = this.user().saveRecords([this], 'addNewRecords'); +// } + + result = this.user().saveRecords([this]); diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js index dbbe9a0..b065557 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/User.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js @@ -287,5 +287,5 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc - 'saveRecords': function(someRecords, aMethodName) { + 'saveRecords': function(someRecords /*, aMethodName*/) { var deferredResult; - var methodName; +// var methodName; var result; @@ -294,3 +294,3 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc //console.log("User.saveRecords - someRecords", someRecords); - methodName = aMethodName || 'addNewRecords'; +// methodName = aMethodName || 'addNewRecords'; @@ -369,3 +369,3 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); deferredResult.addCallback(function(aResult, res) { - aResult['records'].push(res); + aResult['records'] = { 'updated': [res] }; return aResult; @@ -378,3 +378,4 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); - deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); +// deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); + deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); @@ -433,3 +434,4 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); }, someRecords); - someParameters.recordReferences = recordReferences; +// someParameters.recordReferences = recordReferences; + someParameters['records'] = { 'deleted': recordReferences}; @@ -450,3 +452,4 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); - deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); +// deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); + deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); |