Fix / tap on accept shows request button instead of start

This commit is contained in:
Valere 2020-01-02 17:04:21 +01:00
parent bf28f14b8b
commit d1233e8470
4 changed files with 18 additions and 24 deletions

View File

@ -34,7 +34,6 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.*
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@ -48,8 +47,6 @@ internal class SasTransportRoomMessage(
private val tx: SASVerificationTransaction?
) : SasTransport {
private val listenerExecutor = Executors.newSingleThreadExecutor()
override fun sendToOther(type: String,
verificationInfo: VerificationInfo,
nextState: SasVerificationTxState,

View File

@ -152,7 +152,10 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
} else if (it.pendingRequest == null || !it.pendingRequest.isReady) {
// We are waiting for other party to reply with ready
showFragment(VerificationRequestFragment::class, Bundle().apply {
putParcelable(MvRx.KEY_ARG, VerificationArgs(it.otherUserMxItem?.id ?: ""))
putParcelable(MvRx.KEY_ARG, VerificationArgs(
it.otherUserMxItem?.id ?: "",
it.pendingRequest?.transactionId,
it.roomId))
})
} else if (it.pendingRequest.isReady) {
showFragment(VerificationChooseMethodFragment::class, Bundle().apply {

View File

@ -84,13 +84,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
val userItem = session.getUser(args.otherUserId)
val sasTx = state.pendingRequest?.transactionId?.let {
val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
val sasTx = pr?.transactionId?.let {
session.getSasVerificationService().getExistingTransaction(args.otherUserId, it)
}
val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId)
?.firstOrNull { it.transactionId == args.verificationId }
return fragment.verificationViewModelFactory.create(VerificationBottomSheetViewState(
otherUserMxItem = userItem?.toMatrixItem(),
sasTransactionState = sasTx?.state,

View File

@ -44,18 +44,6 @@ class VerificationRequestViewModel @AssistedInject constructor(
}
init {
withState {
val pr = session.getSasVerificationService()
.getExistingVerificationRequest(it.matrixItem.id)
?.firstOrNull()
setState {
copy(
started = Success(false).takeIf { pr == null }
?: Success(true).takeIf { pr?.isReady == true }
?: Loading<Boolean>()
)
}
}
session.getSasVerificationService().addListener(this)
}
@ -71,11 +59,18 @@ class VerificationRequestViewModel @AssistedInject constructor(
}
override fun initialState(viewModelContext: ViewModelContext): VerificationRequestViewState? {
val otherUserId = viewModelContext.args<VerificationBottomSheet.VerificationArgs>().otherUserId
val args = viewModelContext.args<VerificationBottomSheet.VerificationArgs>()
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
return session.getUser(otherUserId)?.let {
VerificationRequestViewState(matrixItem = it.toMatrixItem())
val pr = session.getSasVerificationService()
.getExistingVerificationRequest(args.otherUserId, args.verificationId)
return session.getUser(args.otherUserId)?.let {
VerificationRequestViewState(
started = Success(false).takeIf { pr == null }
?: Success(true).takeIf { pr?.isReady == true }
?: Loading(),
matrixItem = it.toMatrixItem()
)
}
}
}