Add session store logging

// FREEBIE
This commit is contained in:
lilia 2016-02-17 10:46:29 -08:00
parent 1bd0855d93
commit 1e1b87bbbd

View file

@ -167,17 +167,21 @@
},
getSession: function(encodedNumber) {
console.log('getSession', encodedNumber);
if (encodedNumber === null || encodedNumber === undefined)
throw new Error("Tried to get session for undefined/null number");
return new Promise(function(resolve) {
var session = new Session({id: encodedNumber});
console.log('fetching session for', encodedNumber);
session.fetch().always(function() {
console.log('returned session for', encodedNumber);
resolve(session.get('record'));
});
});
},
putSession: function(encodedNumber, record) {
console.log('putSession', encodedNumber);
if (encodedNumber === null || encodedNumber === undefined)
throw new Error("Tried to put session for undefined/null number");
return new Promise(function(resolve) {
@ -185,12 +189,17 @@
var deviceId = parseInt(textsecure.utils.unencodeNumber(encodedNumber)[1]);
var session = new Session({id: encodedNumber});
console.log('fetching session for', encodedNumber);
session.fetch().always(function() {
console.log('saving session for', encodedNumber);
session.save({
record: record,
deviceId: deviceId,
number: number
}).always(resolve);
}).always(function() {
console.log('saved session for', encodedNumber);
resolve();
});
});
});
},