forked from upstream-mirrors/quik
Don't unblock numbers not reported by SIA
This commit is contained in:
@@ -23,7 +23,6 @@ import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.blocking.BlockingClient
|
||||
import com.moez.QKSMS.blocking.BlockingClientCapability
|
||||
import com.moez.QKSMS.interactor.MarkBlocked
|
||||
import com.moez.QKSMS.interactor.MarkUnblocked
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
@@ -55,7 +54,7 @@ class BlockingDialog @Inject constructor(
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (blockingManager.getClientCapability() == BlockingClientCapability.BLOCK_WITHOUT_PERMISSION) {
|
||||
if (blockingManager.getClientCapability() == BlockingClient.Capability.BLOCK_WITHOUT_PERMISSION) {
|
||||
// If we can block/unblock in the external manager, then just fire that off and exit
|
||||
if (block) {
|
||||
markBlocked.execute(conversationIds)
|
||||
@@ -64,7 +63,7 @@ class BlockingDialog @Inject constructor(
|
||||
markUnblocked.execute(conversationIds)
|
||||
blockingManager.unblock(addresses).subscribe()
|
||||
}
|
||||
} else if (addresses.all { address -> block == blockingManager.isBlocked(address).blockingGet() }) {
|
||||
} else if (block == allBlocked(addresses)) {
|
||||
// If all of the addresses are already in their correct state in the blocking manager, just marked the
|
||||
// conversations blocked and exit
|
||||
when (block) {
|
||||
@@ -77,6 +76,10 @@ class BlockingDialog @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun allBlocked(addresses: List<String>): Boolean = addresses.all { address ->
|
||||
blockingManager.getAction(address).blockingGet() == BlockingClient.Action.BLOCK
|
||||
}
|
||||
|
||||
private suspend fun showDialog(
|
||||
activity: Activity,
|
||||
conversationIds: List<Long>,
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ class BlockingManagerPresenter @Inject constructor(
|
||||
.switchMap { numbers -> callControl.block(numbers).andThen(Observable.just(Unit)) } // Hack
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe {
|
||||
callControl.isBlocked("callcontrol").blockingGet()
|
||||
callControl.getAction("callcontrol").blockingGet()
|
||||
analytics.setUserProperty("Blocking Manager", "Call Control")
|
||||
prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_CC)
|
||||
}
|
||||
@@ -142,6 +142,6 @@ class BlockingManagerPresenter @Inject constructor(
|
||||
|
||||
private fun getAddressesToBlock(client: BlockingClient) = conversationRepo.getBlockedConversations()
|
||||
.fold(listOf<String>(), { numbers, conversation -> numbers + conversation.recipients.map { it.address } })
|
||||
.filter { number -> !client.isBlocked(number).blockingGet() }
|
||||
.filter { number -> client.getAction(number).blockingGet() != BlockingClient.Action.BLOCK }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user