mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Mark conversation unblocked right away when unblocking from qk client
This commit is contained in:
@@ -46,6 +46,13 @@ class BlockingRepositoryImpl @Inject constructor() : BlockingRepository {
|
||||
.findAllAsync()
|
||||
}
|
||||
|
||||
override fun getBlockedNumber(id: Long): BlockedNumber? {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
return realm.where(BlockedNumber::class.java)
|
||||
.equalTo("id", id)
|
||||
.findFirst()
|
||||
}
|
||||
|
||||
override fun isBlocked(address: String): Boolean {
|
||||
return Realm.getDefaultInstance().use { realm ->
|
||||
realm.where(BlockedNumber::class.java)
|
||||
|
||||
@@ -27,6 +27,8 @@ interface BlockingRepository {
|
||||
|
||||
fun getBlockedNumbers(): RealmResults<BlockedNumber>
|
||||
|
||||
fun getBlockedNumber(id: Long): BlockedNumber?
|
||||
|
||||
fun isBlocked(address: String): Boolean
|
||||
|
||||
fun unblockNumber(id: Long)
|
||||
|
||||
+14
-2
@@ -19,13 +19,18 @@
|
||||
package com.moez.QKSMS.feature.blocking.numbers
|
||||
|
||||
import com.moez.QKSMS.common.base.QkPresenter
|
||||
import com.moez.QKSMS.interactor.MarkUnblocked
|
||||
import com.moez.QKSMS.repository.BlockingRepository
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedNumbersPresenter @Inject constructor(
|
||||
private val blockingRepo: BlockingRepository
|
||||
private val blockingRepo: BlockingRepository,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val markUnblocked: MarkUnblocked
|
||||
) : QkPresenter<BlockedNumbersView, BlockedNumbersState>(
|
||||
BlockedNumbersState(numbers = blockingRepo.getBlockedNumbers())
|
||||
) {
|
||||
@@ -34,7 +39,13 @@ class BlockedNumbersPresenter @Inject constructor(
|
||||
super.bindIntents(view)
|
||||
|
||||
view.unblockAddress()
|
||||
.doOnNext { id ->
|
||||
blockingRepo.getBlockedNumber(id)?.address
|
||||
?.let(conversationRepo::getThreadId)
|
||||
?.let { threadId -> markUnblocked.execute(listOf(threadId)) }
|
||||
}
|
||||
.doOnNext(blockingRepo::unblockNumber)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
@@ -43,8 +54,9 @@ class BlockedNumbersPresenter @Inject constructor(
|
||||
.subscribe { view.showAddDialog() }
|
||||
|
||||
view.saveAddress()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe{ address -> blockingRepo.blockNumber(address) }
|
||||
.subscribe { address -> blockingRepo.blockNumber(address) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user