Clear alert when device is verified

This commit is contained in:
Valere 2020-03-24 15:21:03 +01:00
parent cfcec04029
commit fcffe1f3c3
3 changed files with 13 additions and 8 deletions

View File

@ -78,7 +78,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
} else true
})
.apply {
matrixItem = session?.getUser(tx.otherUserId ?: "")?.toMatrixItem()
matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem()
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {

View File

@ -43,6 +43,7 @@ import im.vector.riotx.features.home.room.list.RoomListParams
import im.vector.riotx.features.home.room.list.UnreadCounterBadgeView
import im.vector.riotx.features.popup.PopupAlertManager
import im.vector.riotx.features.popup.VectorAlert
import im.vector.riotx.features.popup.VerificationVectorAlert
import im.vector.riotx.features.workers.signout.SignOutViewModel
import kotlinx.android.synthetic.main.fragment_home_detail.*
import timber.log.Timber
@ -93,13 +94,13 @@ class HomeDetailFragment @Inject constructor(
unknownDevices.forEachIndexed { index, deviceInfo ->
Timber.v("## Detector - #$index deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}")
}
val uid = "Newest_Device"
alertManager.cancelAlert(uid)
if (it.canCrossSign && unknownDevices.isNotEmpty()) {
val newest = unknownDevices.first().second
val user = unknownDevices.first().first
val uid = "ND_${newest.deviceId}"
alertManager.cancelAlert(uid)
alertManager.postVectorAlert(
VectorAlert(
VerificationVectorAlert(
uid = uid,
title = getString(R.string.new_session),
description = getString(R.string.new_session_review),

View File

@ -36,8 +36,7 @@ import im.vector.riotx.core.platform.VectorViewModel
import io.reactivex.android.schedulers.AndroidSchedulers
data class UnknownDevicesState(
val unknownSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
val verifiedSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
val unknownSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>> = Uninitialized,
val canCrossSign: Boolean = false
) : MvRxState
@ -47,16 +46,21 @@ class UnknownDeviceDetectorSharedViewModel(session: Session, initialState: Unkno
session.rx().liveUserCryptoDevices(session.myUserId)
.observeOn(AndroidSchedulers.mainThread())
.switchMap { deviceList ->
// Timber.v("## Detector - ============================")
// Timber.v("## Detector - Crypto device update ${deviceList.map { "${it.deviceId} : ${it.isVerified}" }}")
singleBuilder<DevicesListResponse> {
session.cryptoService().getDevicesList(it)
NoOpCancellable
}.map { resp ->
// Timber.v("## Detector - Device Infos ${resp.devices?.map { "${it.deviceId} : lastSeen:${it.lastSeenTs}" }}")
resp.devices?.filter { info ->
deviceList.firstOrNull { info.deviceId == it.deviceId }?.isVerified?.not() ?: false
deviceList.firstOrNull { info.deviceId == it.deviceId }?.let {
!it.isVerified
} ?: false
}?.sortedByDescending { it.lastSeenTs }
?.map {
session.getUser(it.user_id ?: "")?.toMatrixItem() to it
}
} ?: emptyList()
}
.toObservable()
}