summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz
authorClipperz <info@clipperz.com>2013-01-08 15:17:30 (UTC)
committer Clipperz <info@clipperz.com>2013-01-08 15:17:30 (UTC)
commit267603e3aa3cf0029411e67ae14018b52344c296 (patch) (side-by-side diff)
tree055e8f8d8543ed6bfa342dbf4641fea308c2ec5a /frontend/beta/js/Clipperz
parentb6a11a37ec3271bd44fc23b9da00c5b052b0d8b9 (diff)
downloadclipperz-267603e3aa3cf0029411e67ae14018b52344c296.zip
clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.gz
clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.bz2
Fixed corrupted card problem
Changes that check for a weird condition that was causing cards to get corrupted. A similar change has been applied also to /gamma (in a different commit, though)
Diffstat (limited to 'frontend/beta/js/Clipperz') (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
@@ -296,11 +296,15 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log
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);
@@ -577,5 +581,6 @@ 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
@@ -639,11 +639,13 @@ 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;
},
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
@@ -285,14 +285,14 @@ 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);
//MochiKit.Logging.logDebug(">>> User.saveRecords");
@@ -367,7 +367,7 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
//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;});
@@ -376,7 +376,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
//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++) {
@@ -431,7 +432,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
return result;
}, someRecords);
- someParameters.recordReferences = recordReferences;
+// someParameters.recordReferences = recordReferences;
+ someParameters['records'] = { 'deleted': recordReferences};
return someParameters;
}, parameters);
@@ -448,7 +450,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
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;});