summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Connection.js9
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/Record.js12
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/User.js17
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
@@ -297,9 +297,13 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log
this.user().setLoginInfo(someParameters['loginInfo']);
this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']);
- this.user().setLock(someParameters['lock']);
+
+ if ((isReconnecting == true) && (this.user().lock() != someParameters['lock'])) {
+ throw Clipperz.PM.Connection.exception.StaleData;
+ }
if (this.oneTimePassword() != null) {
result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword()));
}
+
result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn');
result.addCallback(MochiKit.Async.succeed, someParameters);
@@ -578,4 +582,5 @@ 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
@@ -640,9 +640,11 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam
var result;
- 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]);
return result;
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
@@ -286,12 +286,12 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc
//-------------------------------------------------------------------------
- 'saveRecords': function(someRecords, aMethodName) {
+ 'saveRecords': function(someRecords /*, aMethodName*/) {
var deferredResult;
- var methodName;
+// var methodName;
var result;
var i,c;
//console.log("User.saveRecords - someRecords", someRecords);
- methodName = aMethodName || 'addNewRecords';
+// methodName = aMethodName || 'addNewRecords';
Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true);
@@ -368,5 +368,5 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
deferredResult.addCallback(function(aResult, res) {
- aResult['records'].push(res);
+ aResult['records'] = { 'updated': [res] };
return aResult;
}, result);
@@ -377,5 +377,6 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData');
//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;});
@@ -432,5 +433,6 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
return result;
}, someRecords);
- someParameters.recordReferences = recordReferences;
+// someParameters.recordReferences = recordReferences;
+ someParameters['records'] = { 'deleted': recordReferences};
return someParameters;
@@ -449,5 +451,6 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;});
//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;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface');