Serialize prekey refreshes & other account mgmt

Fixes #1060

// FREEBIE
This commit is contained in:
lilia 2017-02-14 11:27:59 -08:00
parent a98857a1d1
commit dfc292ac70
3 changed files with 146 additions and 119 deletions

View file

@ -44,20 +44,23 @@
return -1;
}
};
var accountManager;
window.getAccountManager = function() {
var USERNAME = storage.get('number_id');
var PASSWORD = storage.get('password');
var accountManager = new textsecure.AccountManager(
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
);
accountManager.addEventListener('registration', function() {
if (!Whisper.Registration.everDone()) {
storage.put('safety-numbers-approval', false);
}
Whisper.Registration.markDone();
console.log("dispatching registration event");
extension.trigger('registration_done');
});
if (!accountManager) {
var USERNAME = storage.get('number_id');
var PASSWORD = storage.get('password');
accountManager = new textsecure.AccountManager(
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
);
accountManager.addEventListener('registration', function() {
if (!Whisper.Registration.everDone()) {
storage.put('safety-numbers-approval', false);
}
Whisper.Registration.markDone();
console.log("dispatching registration event");
extension.trigger('registration_done');
});
}
return accountManager;
};