Move refresh prekeys out of SignalProtocolStore

Use an event/listener instead

// FREEBIE
This commit is contained in:
lilia 2017-05-22 15:24:24 -07:00 committed by Scott Nonnenberg
parent 681418cf6b
commit 16f3717824
3 changed files with 10 additions and 22 deletions

View file

@ -21,6 +21,9 @@
// start a background worker for ecc
textsecure.startWorker('/js/libsignal-protocol-worker.js');
Whisper.KeyChangeListener.init(textsecure.storage.protocol);
textsecure.storage.protocol.on('removePreKey', function() {
getAccountManager().refreshPreKeys();
});
extension.onLaunched(function() {
console.log('extension launched');

View file

@ -136,16 +136,13 @@
removePreKey: function(keyId) {
var prekey = new PreKey({id: keyId});
return Promise.all([
new Promise(function(resolve) {
getAccountManager().refreshPreKeys().then(resolve);
}),
new Promise(function(resolve) {
prekey.destroy().then(function() {
resolve();
});
})
]);
this.trigger('removePreKey');
return new Promise(function(resolve) {
prekey.destroy().then(function() {
resolve();
});
});
},
/* Returns a signed keypair object or undefined */