Don't delete all data if e164 changes (focus on UUID if we have it)

This commit is contained in:
Scott Nonnenberg 2021-06-08 11:54:20 -07:00 committed by GitHub
parent a918b06841
commit 13371fbeb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -538,20 +538,23 @@ export default class AccountManager extends EventTarget {
{ accessKey } { accessKey }
); );
const numberChanged = previousNumber && previousNumber !== number;
const uuidChanged = previousUuid && uuid && previousUuid !== uuid; const uuidChanged = previousUuid && uuid && previousUuid !== uuid;
if (numberChanged || uuidChanged) { // We only consider the number changed if we didn't have a UUID before
if (numberChanged) { const numberChanged =
window.log.warn( !previousUuid && previousNumber && previousNumber !== number;
'New number is different from old number; deleting all previous data'
); if (uuidChanged || numberChanged) {
}
if (uuidChanged) { if (uuidChanged) {
window.log.warn( window.log.warn(
'New uuid is different from old uuid; deleting all previous data' 'New uuid is different from old uuid; deleting all previous data'
); );
} }
if (numberChanged) {
window.log.warn(
'New number is different from old number; deleting all previous data'
);
}
try { try {
await window.textsecure.storage.protocol.removeAllData(); await window.textsecure.storage.protocol.removeAllData();