~singpolyma/cheogram-android

1497227354fca9e30fe6f88dcb6eb4295ca6195d — Stephen Paul Weber 8 months ago cc26170
Track sync attempts per-account

So that one account doesn't override another's attempt to sync
M src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java => src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java +3 -3
@@ 27,7 27,7 @@ public class QuickConversationsService extends AbstractQuickConversationsService

    protected final AtomicInteger mRunningSyncJobs = new AtomicInteger(0);
    protected final SerialSingleThreadExecutor mSerialSingleThreadExecutor = new SerialSingleThreadExecutor(QuickConversationsService.class.getSimpleName());
    protected Attempt mLastSyncAttempt = Attempt.NULL;
    protected HashMap<String,Attempt> mLastSyncAttempt = new HashMap<>();

    QuickConversationsService(XmppConnectionService xmppConnectionService) {
        super(xmppConnectionService);


@@ 122,13 122,13 @@ public class QuickConversationsService extends AbstractQuickConversationsService
    protected boolean considerSync(final Account account, final List<String> gateways, final Map<String, PhoneNumberContact> contacts, final boolean forced) {
        final int hash = Objects.hash(contacts.keySet(), gateways);
        Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": consider sync of " + hash);
        if (!mLastSyncAttempt.retry(hash) && !forced) {
        if (!mLastSyncAttempt.getOrDefault(account.getUuid(), Attempt.NULL).retry(hash) && !forced) {
            Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not attempt sync");
            return false;
        }
        mRunningSyncJobs.incrementAndGet();

        mLastSyncAttempt = Attempt.create(hash);
        mLastSyncAttempt.put(account.getUuid(), Attempt.create(hash));
        final List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts(PhoneNumberContact.class);
        for (Map.Entry<String, PhoneNumberContact> item : contacts.entrySet()) {
            PhoneNumberContact phoneContact = item.getValue();