diff --git a/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt b/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt index b81a7c831..3b09f6d25 100644 --- a/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt @@ -52,13 +52,22 @@ class ChangelogManagerImpl @Inject constructor( return Single .create { emitter -> + call?.enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + if (!emitter.isDisposed) { + emitter.onSuccess(response) + } + } + + override fun onFailure(call: Call, e: IOException) { + if (!emitter.isDisposed) { + emitter.onError(e) + } + } + }) emitter.setCancellable { call?.cancel() } - call?.enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) = emitter.onSuccess(response) - override fun onFailure(call: Call, e: IOException) = emitter.onError(e) - }) } .map { response -> response.body?.string()?.let(adapter::fromJson) } .map { response -> diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index 645ee60c1..f25a96398 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -49,7 +49,6 @@ import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.withLatestFrom import io.reactivex.schedulers.Schedulers import io.realm.Realm -import timber.log.Timber import java.util.* import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -160,7 +159,7 @@ class MainViewModel @Inject constructor( .subscribe({ changelog -> changelogManager.markChangelogSeen() view.showChangelog(changelog) - }, Timber::w) + }, {}) // Ignore error } else { changelogManager.markChangelogSeen() }