forked from upstream-mirrors/quik
Provide explicit threadId when showing unblock confirmation dialog
This commit is contained in:
@@ -39,7 +39,7 @@ class BlockedActivity : QkThemedActivity(), BlockedView {
|
||||
|
||||
override val siaClickedIntent by lazy { shouldIAnswer.clicks() }
|
||||
override val unblockIntent by lazy { blockedAdapter.unblock }
|
||||
override val confirmUnblockIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val confirmUnblockIntent: Subject<Long> = PublishSubject.create()
|
||||
|
||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[BlockedViewModel::class.java] }
|
||||
|
||||
@@ -61,11 +61,11 @@ class BlockedActivity : QkThemedActivity(), BlockedView {
|
||||
blockedAdapter.updateData(state.data)
|
||||
}
|
||||
|
||||
override fun showUnblockDialog() {
|
||||
override fun showUnblockDialog(threadId: Long) {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.blocked_unblock_dialog_title)
|
||||
.setMessage(R.string.blocked_unblock_dialog_message)
|
||||
.setPositiveButton(R.string.button_unblock) { _, _ -> confirmUnblockIntent.onNext(Unit) }
|
||||
.setPositiveButton(R.string.button_unblock) { _, _ -> confirmUnblockIntent.onNext(threadId) }
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ interface BlockedView : QkView<BlockedState> {
|
||||
|
||||
val siaClickedIntent: Observable<*>
|
||||
val unblockIntent: Observable<Long>
|
||||
val confirmUnblockIntent: Observable<*>
|
||||
val confirmUnblockIntent: Observable<Long>
|
||||
|
||||
fun showUnblockDialog()
|
||||
fun showUnblockDialog(threadId: Long)
|
||||
|
||||
}
|
||||
@@ -68,11 +68,10 @@ class BlockedViewModel @Inject constructor(
|
||||
// Show confirm unblock conversation dialog
|
||||
view.unblockIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showUnblockDialog() }
|
||||
.subscribe { threadId -> view.showUnblockDialog(threadId) }
|
||||
|
||||
// Unblock conversation
|
||||
view.confirmUnblockIntent
|
||||
.withLatestFrom(view.unblockIntent) { _, threadId -> threadId }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { threadId -> markUnblocked.execute(listOf(threadId)) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user