forked from upstream-mirrors/quik
Allow blocking thread to complete before being disposed.
If we call dispose after subscribe the process doesn't get to complete, leaving the notification, and eventually crashing the app. SupressLint is necessary to avoid warnings on not calling dispose.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.receiver
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -27,6 +28,7 @@ import dev.octoshrimpy.quik.interactor.MarkBlocked
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockThreadReceiver : BroadcastReceiver() {
|
||||
@@ -36,6 +38,7 @@ class BlockThreadReceiver : BroadcastReceiver() {
|
||||
@Inject lateinit var markBlocked: MarkBlocked
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
AndroidInjection.inject(this, context)
|
||||
|
||||
@@ -54,8 +57,14 @@ class BlockThreadReceiver : BroadcastReceiver() {
|
||||
MarkBlocked.Params(listOf(threadId), prefs.blockingManager.get(), null)
|
||||
)
|
||||
)
|
||||
.subscribe { goAsync().finish() }
|
||||
.dispose()
|
||||
.subscribe(
|
||||
{
|
||||
goAsync().finish()
|
||||
},
|
||||
{ error ->
|
||||
Timber.e("BlockThreadReceiver", "blocking failed")
|
||||
goAsync().finish()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user