Cache synchronizing identities

pull/198/head
M66B 4 years ago
parent 344d826325
commit c1f104b3ed

@ -94,7 +94,6 @@ public class ContactInfo {
private static Map<String, Lookup> emailLookup = new ConcurrentHashMap<>();
private static final Map<String, ContactInfo> emailContactInfo = new HashMap<>();
private static final Map<String, Avatar> emailGravatar = new HashMap<>();
private static final Map<Long, List<EntityIdentity>> accountIdentities = new HashMap<>();
private static final ExecutorService executorLookup =
Helper.getBackgroundExecutor(1, "contact");
@ -194,12 +193,6 @@ public class ContactInfo {
});
}
static void clearIdentities() {
synchronized (accountIdentities) {
accountIdentities.clear();
}
}
@NonNull
static ContactInfo[] get(Context context, long account, String folderType, Address[] addresses) {
return get(context, account, folderType, addresses, false);
@ -757,14 +750,7 @@ public class ContactInfo {
// Check if from self
if (type == EntityContact.TYPE_FROM) {
if (message.from != null) {
List<EntityIdentity> identities;
synchronized (accountIdentities) {
if (!accountIdentities.containsKey(folder.account))
accountIdentities.put(folder.account,
db.identity().getSynchronizingIdentities(folder.account));
identities = accountIdentities.get(folder.account);
}
List<EntityIdentity> identities = Core.getIdentities(folder.account, context);
if (identities != null) {
for (Address sender : message.from) {
for (EntityIdentity identity : identities)

@ -158,6 +158,23 @@ class Core {
private static final int FIND_RETRY_COUNT = 3; // times
private static final long FIND_RETRY_DELAY = 5 * 1000L; // milliseconds
private static final Map<Long, List<EntityIdentity>> accountIdentities = new HashMap<>();
static void clearIdentities() {
synchronized (accountIdentities) {
accountIdentities.clear();
}
}
static List<EntityIdentity> getIdentities(long account, Context context) {
synchronized (accountIdentities) {
if (!accountIdentities.containsKey(account))
accountIdentities.put(account,
DB.getInstance(context).identity().getSynchronizingIdentities(account));
return accountIdentities.get(account);
}
}
static void processOperations(
Context context,
EntityAccount account, EntityFolder folder, List<TupleOperationEx> ops,
@ -3603,7 +3620,7 @@ class Core {
}
// Search for matching identity
List<EntityIdentity> identities = db.identity().getSynchronizingIdentities(folder.account);
List<EntityIdentity> identities = getIdentities(folder.account, context);
if (identities != null) {
for (Address address : addresses)
for (EntityIdentity identity : identities)

@ -990,7 +990,7 @@ public class FragmentIdentity extends FragmentBase {
db.endTransaction();
}
ContactInfo.clearIdentities();
Core.clearIdentities();
return false;
}
@ -1376,7 +1376,7 @@ public class FragmentIdentity extends FragmentBase {
DB db = DB.getInstance(context);
db.identity().deleteIdentity(id);
ContactInfo.clearIdentities();
Core.clearIdentities();
return null;
}

Loading…
Cancel
Save