summaryrefslogtreecommitdiff
path: root/frontend/beta/js
Side-by-side diff
Diffstat (limited to 'frontend/beta/js') (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
@@ -293,17 +293,21 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log
result = new MochiKit.Async.Deferred();
//MochiKit.Logging.logDebug("--- Connection.loginDone - someParameters: " + Clipperz.Base.serializeJSON(someParameters));
this.setConnectionId(someParameters['connectionId']);
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);
result.callback();
//MochiKit.Logging.logDebug("--- Connection.loginDone - 1 - result: "/* + Clipperz.Base.serializeJSON(result)*/);
} else {
@@ -574,8 +578,9 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz.
//-----------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
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
@@ -636,17 +636,19 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam
//-------------------------------------------------------------------------
'saveChanges': function() {
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;
},
/*
'saveChanges': function() {
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
@@ -282,20 +282,20 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc
return record;
},
//-------------------------------------------------------------------------
- '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);
//MochiKit.Logging.logDebug(">>> User.saveRecords");
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords");
/*
MochiKit.Logging.logDebug("--- User.saveRecords - 1");
@@ -364,22 +364,23 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
aResult['currentRecordVersion'] = res;
return aResult;
}, recordData);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;});
deferredResult.addCallback(function(aResult, res) {
- aResult['records'].push(res);
+ aResult['records'] = { 'updated': [res] };
return aResult;
}, result);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;});
}
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;});
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;});
for (i=0; i<c; i++) {
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData'));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;});
@@ -428,13 +429,14 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
result = aRecord.reference();
aRecord.remove();
return result;
}, someRecords);
- someParameters.recordReferences = recordReferences;
+// someParameters.recordReferences = recordReferences;
+ someParameters['records'] = { 'deleted': recordReferences};
return someParameters;
}, parameters);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;});
@@ -445,13 +447,14 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
return someParameters;
}, parameters);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData');
//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');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;});
deferredResult.callback(someRecords);
//MochiKit.Logging.logDebug("<<< User.deleteRecordsAction");