Don't invalidate entire recipient cache when contact data changes

This commit is contained in:
Moxie Marlinspike
2017-11-20 14:48:39 -08:00
parent 8f6440ce17
commit 66e1be1aeb
9 changed files with 92 additions and 198 deletions

View File

@@ -38,14 +38,10 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.ContactTokenDetails;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -80,13 +76,12 @@ public class ContactsDatabase {
this.context = context;
}
public synchronized @NonNull List<Address> setRegisteredUsers(@NonNull Account account,
@NonNull List<Address> registeredAddressList,
boolean remove)
public synchronized void setRegisteredUsers(@NonNull Account account,
@NonNull List<Address> registeredAddressList,
boolean remove)
throws RemoteException, OperationApplicationException
{
Set<Address> registeredAddressSet = new HashSet<>();
List<Address> addedAddresses = new LinkedList<>();
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
Map<Address, SignalContact> currentContacts = getSignalRawContacts(account);
@@ -98,7 +93,6 @@ public class ContactsDatabase {
if (systemContactInfo.isPresent()) {
Log.w(TAG, "Adding number: " + registeredAddress);
addedAddresses.add(registeredAddress);
addTextSecureRawContact(operations, account, systemContactInfo.get().number,
systemContactInfo.get().name, systemContactInfo.get().id,
true);
@@ -126,8 +120,6 @@ public class ContactsDatabase {
if (!operations.isEmpty()) {
context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
}
return addedAddresses;
}
@NonNull Cursor querySystemContacts(@Nullable String filter) {