Merge branch 'fix-contact-sync'

Stephen Paul Weber created

* fix-contact-sync:
  Contact sync needs to happen when we discover a new gateway
  Skip contact sync work if there are no gateways configured

Change summary

src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java | 4 
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java         | 2 
2 files changed, 5 insertions(+), 1 deletion(-)

Detailed changes

src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java 🔗

@@ -97,9 +97,11 @@ public class QuickConversationsService extends AbstractQuickConversationsService
     }
 
     protected void considerSync(boolean forced) {
-        final ImmutableMap<String, PhoneNumberContact> allContacts = PhoneNumberContact.load(service);
+        ImmutableMap<String, PhoneNumberContact> allContacts = null;
         for (final Account account : service.getAccounts()) {
             List<String> gateways = gateways(account);
+            if (gateways.size() < 1) continue;
+            if (allContacts == null) allContacts = PhoneNumberContact.load(service);
             refresh(account, gateways, allContacts.values());
             if (!considerSync(account, gateways, allContacts, forced)) {
                 service.syncRoster(account);

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java 🔗

@@ -4694,6 +4694,7 @@ public class XmppConnectionService extends Service {
             }
             if (disco.hasIdentity("gateway", "pstn")) {
                 contact.registerAsPhoneAccount(this);
+                mQuickConversationsService.considerSyncBackground(false);
             }
         } else {
             final IqPacket request = new IqPacket(IqPacket.TYPE.GET);
@@ -4714,6 +4715,7 @@ public class XmppConnectionService extends Service {
                         if (discoveryResult.hasIdentity("gateway", "pstn")) {
                             final Contact contact = account.getRoster().getContact(jid);
                             contact.registerAsPhoneAccount(this);
+                            mQuickConversationsService.considerSyncBackground(false);
                         }
                     } else {
                         Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + discoveryResult.getVer());