Async putSessionsForDevice
This commit is contained in:
parent
666f6baaca
commit
26f1aa4db5
3 changed files with 37 additions and 35 deletions
|
@ -177,9 +177,7 @@
|
|||
putSession: function(identifier, record) {
|
||||
if (identifier === null || identifier === undefined)
|
||||
throw new Error("Tried to put session for undefined/null key");
|
||||
return new Promise(function(resolve) {
|
||||
resolve(textsecure.storage.sessions.putSessionsForDevice(identifier, record));
|
||||
});
|
||||
return textsecure.storage.sessions.putSessionsForDevice(identifier, record);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -38111,24 +38111,26 @@ axolotlInternal.RecipientRecord = function() {
|
|||
},
|
||||
|
||||
putSessionsForDevice: function(encodedNumber, record) {
|
||||
var number = textsecure.utils.unencodeNumber(encodedNumber)[0];
|
||||
var deviceId = textsecure.utils.unencodeNumber(encodedNumber)[1];
|
||||
return Promise.resolve((function() {
|
||||
var number = textsecure.utils.unencodeNumber(encodedNumber)[0];
|
||||
var deviceId = textsecure.utils.unencodeNumber(encodedNumber)[1];
|
||||
|
||||
var sessions = textsecure.storage.get("sessions" + number);
|
||||
if (sessions === undefined)
|
||||
sessions = {};
|
||||
sessions[deviceId] = record;
|
||||
textsecure.storage.put("sessions" + number, sessions);
|
||||
var sessions = textsecure.storage.get("sessions" + number);
|
||||
if (sessions === undefined)
|
||||
sessions = {};
|
||||
sessions[deviceId] = record;
|
||||
textsecure.storage.put("sessions" + number, sessions);
|
||||
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber);
|
||||
if (device === undefined) {
|
||||
var identityKey = textsecure.storage.devices.getIdentityKeyForNumber(number);
|
||||
device = { encodedNumber: encodedNumber,
|
||||
//TODO: Remove this duplication
|
||||
identityKey: identityKey
|
||||
};
|
||||
}
|
||||
return textsecure.storage.devices.saveDeviceObject(device);
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber);
|
||||
if (device === undefined) {
|
||||
var identityKey = textsecure.storage.devices.getIdentityKeyForNumber(number);
|
||||
device = { encodedNumber: encodedNumber,
|
||||
//TODO: Remove this duplication
|
||||
identityKey: identityKey
|
||||
};
|
||||
}
|
||||
return textsecure.storage.devices.saveDeviceObject(device);
|
||||
})());
|
||||
},
|
||||
|
||||
// Use textsecure.storage.devices.removeIdentityKeyForNumber (which calls this) instead
|
||||
|
|
|
@ -40,24 +40,26 @@
|
|||
},
|
||||
|
||||
putSessionsForDevice: function(encodedNumber, record) {
|
||||
var number = textsecure.utils.unencodeNumber(encodedNumber)[0];
|
||||
var deviceId = textsecure.utils.unencodeNumber(encodedNumber)[1];
|
||||
return Promise.resolve((function() {
|
||||
var number = textsecure.utils.unencodeNumber(encodedNumber)[0];
|
||||
var deviceId = textsecure.utils.unencodeNumber(encodedNumber)[1];
|
||||
|
||||
var sessions = textsecure.storage.get("sessions" + number);
|
||||
if (sessions === undefined)
|
||||
sessions = {};
|
||||
sessions[deviceId] = record;
|
||||
textsecure.storage.put("sessions" + number, sessions);
|
||||
var sessions = textsecure.storage.get("sessions" + number);
|
||||
if (sessions === undefined)
|
||||
sessions = {};
|
||||
sessions[deviceId] = record;
|
||||
textsecure.storage.put("sessions" + number, sessions);
|
||||
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber);
|
||||
if (device === undefined) {
|
||||
var identityKey = textsecure.storage.devices.getIdentityKeyForNumber(number);
|
||||
device = { encodedNumber: encodedNumber,
|
||||
//TODO: Remove this duplication
|
||||
identityKey: identityKey
|
||||
};
|
||||
}
|
||||
return textsecure.storage.devices.saveDeviceObject(device);
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber);
|
||||
if (device === undefined) {
|
||||
var identityKey = textsecure.storage.devices.getIdentityKeyForNumber(number);
|
||||
device = { encodedNumber: encodedNumber,
|
||||
//TODO: Remove this duplication
|
||||
identityKey: identityKey
|
||||
};
|
||||
}
|
||||
return textsecure.storage.devices.saveDeviceObject(device);
|
||||
})());
|
||||
},
|
||||
|
||||
// Use textsecure.storage.devices.removeIdentityKeyForNumber (which calls this) instead
|
||||
|
|
Loading…
Reference in a new issue