Skip contact sync work if there are no gateways configured

Stephen Paul Weber created

Or if syncing before gateways have been discovered, etc.  Don't do the work if
we know nothing will come of it.

Change summary

src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java | 4 
1 file changed, 3 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);