Move refresh prekeys out of SignalProtocolStore
Use an event/listener instead // FREEBIE
This commit is contained in:
parent
681418cf6b
commit
16f3717824
3 changed files with 10 additions and 22 deletions
|
@ -21,6 +21,9 @@
|
||||||
// start a background worker for ecc
|
// start a background worker for ecc
|
||||||
textsecure.startWorker('/js/libsignal-protocol-worker.js');
|
textsecure.startWorker('/js/libsignal-protocol-worker.js');
|
||||||
Whisper.KeyChangeListener.init(textsecure.storage.protocol);
|
Whisper.KeyChangeListener.init(textsecure.storage.protocol);
|
||||||
|
textsecure.storage.protocol.on('removePreKey', function() {
|
||||||
|
getAccountManager().refreshPreKeys();
|
||||||
|
});
|
||||||
|
|
||||||
extension.onLaunched(function() {
|
extension.onLaunched(function() {
|
||||||
console.log('extension launched');
|
console.log('extension launched');
|
||||||
|
|
|
@ -136,16 +136,13 @@
|
||||||
removePreKey: function(keyId) {
|
removePreKey: function(keyId) {
|
||||||
var prekey = new PreKey({id: keyId});
|
var prekey = new PreKey({id: keyId});
|
||||||
|
|
||||||
return Promise.all([
|
this.trigger('removePreKey');
|
||||||
new Promise(function(resolve) {
|
|
||||||
getAccountManager().refreshPreKeys().then(resolve);
|
return new Promise(function(resolve) {
|
||||||
}),
|
prekey.destroy().then(function() {
|
||||||
new Promise(function(resolve) {
|
resolve();
|
||||||
prekey.destroy().then(function() {
|
});
|
||||||
resolve();
|
});
|
||||||
});
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Returns a signed keypair object or undefined */
|
/* Returns a signed keypair object or undefined */
|
||||||
|
|
|
@ -91,21 +91,9 @@ describe("SignalProtocolStore", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('removePreKey', function() {
|
describe('removePreKey', function() {
|
||||||
var oldGetAccountManager;
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
oldGetAccountManager = window.getAccountManager;
|
|
||||||
window.getAccountManager = function() {
|
|
||||||
return {
|
|
||||||
refreshPreKeys: function() {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
store.storePreKey(2, testKey).then(done);
|
store.storePreKey(2, testKey).then(done);
|
||||||
});
|
});
|
||||||
after(function() {
|
|
||||||
window.getAccountManager = oldGetAccountManager;
|
|
||||||
});
|
|
||||||
it('deletes prekeys', function(done) {
|
it('deletes prekeys', function(done) {
|
||||||
store.removePreKey(2, testKey).then(function() {
|
store.removePreKey(2, testKey).then(function() {
|
||||||
return store.loadPreKey(2).then(function(key) {
|
return store.loadPreKey(2).then(function(key) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue