Remove config after unlink, clear db when linked with new number

This commit is contained in:
Scott Nonnenberg 2018-02-23 17:40:02 -08:00 committed by Scott Nonnenberg
parent fd056e1b4c
commit 9acb189650
No known key found for this signature in database
GPG key ID: 5F82280C35134661
7 changed files with 108 additions and 11 deletions

View file

@ -171,18 +171,18 @@
constructor: SignalProtocolStore,
getIdentityKeyPair: function() {
var item = new Item({id: 'identityKey'});
return new Promise(function(resolve) {
return new Promise(function(resolve, reject) {
item.fetch().then(function() {
resolve(item.get('value'));
});
}, reject);
});
},
getLocalRegistrationId: function() {
var item = new Item({id: 'registrationId'});
return new Promise(function(resolve) {
return new Promise(function(resolve, reject) {
item.fetch().then(function() {
resolve(item.get('value'));
});
}, reject);
});
},
@ -854,6 +854,37 @@
return unprocessed.destroy().then(resolve, reject);
}.bind(this));
},
removeAllData: function() {
// First the in-memory caches:
window.storage.reset(); // items store
ConversationController.reset(); // conversations store
// Then, the database. All stores:
// items
// identityKeys
// sessions
// signedPreKeys
// preKeys
// unprocessed
// groups
// conversations
// messages
return window.Whisper.Backup.clearDatabase();
},
removeAllConfiguration: function() {
// First the in-memory cache for the items store:
window.storage.reset();
// Then anything in the database that isn't a message/conversation/group:
return window.Whisper.Backup.clearStores([
'items',
'identityKeys',
'sessions',
'signedPreKeys',
'preKeys',
'unprocessed',
]);
}
};
_.extend(SignalProtocolStore.prototype, Backbone.Events);