also error sending fixed

This commit is contained in:
Gavriil Sitnikov 2016-10-18 21:24:36 +03:00
parent 890a14969b
commit 2819a5ab73
1 changed files with 8 additions and 5 deletions

View File

@ -188,12 +188,15 @@ public abstract class Chat<TOutgoingMessage> {
.subscribeOn(Schedulers.computation())
.first()
.switchMap(shouldSendMessage -> shouldSendMessage ? createSendMessageObservable(message).ignoreElements() : Observable.empty())
.retryWhen(attempts -> attempts.switchMap(ignored -> Observable
.merge(retrySendingRequest, Observable.timer(RETRY_SENDING_DELAY, TimeUnit.MILLISECONDS))
.first()
.doOnCompleted(() -> isSendingInError.onNext(false))))
.retryWhen(attempts -> attempts.switchMap(ignored -> {
isSendingInError.onNext(true);
return Observable
.merge(retrySendingRequest, Observable.timer(RETRY_SENDING_DELAY, TimeUnit.MILLISECONDS))
.first()
.doOnCompleted(() -> isSendingInError.onNext(false));
}))
.doOnUnsubscribe(blocker::countDown)
.subscribe(Actions.empty(), throwable -> isSendingInError.onNext(true), () -> sendingMessages.remove(message));
.subscribe(Actions.empty(), Lc::assertion, () -> sendingMessages.remove(message));
try {
blocker.await();
} catch (final InterruptedException exception) {