Clear alert when device is verified
This commit is contained in:
parent
cfcec04029
commit
fcffe1f3c3
|
@ -78,7 +78,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
||||||
} else true
|
} else true
|
||||||
})
|
})
|
||||||
.apply {
|
.apply {
|
||||||
matrixItem = session?.getUser(tx.otherUserId ?: "")?.toMatrixItem()
|
matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem()
|
||||||
|
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
|
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
|
||||||
|
|
|
@ -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.home.room.list.UnreadCounterBadgeView
|
||||||
import im.vector.riotx.features.popup.PopupAlertManager
|
import im.vector.riotx.features.popup.PopupAlertManager
|
||||||
import im.vector.riotx.features.popup.VectorAlert
|
import im.vector.riotx.features.popup.VectorAlert
|
||||||
|
import im.vector.riotx.features.popup.VerificationVectorAlert
|
||||||
import im.vector.riotx.features.workers.signout.SignOutViewModel
|
import im.vector.riotx.features.workers.signout.SignOutViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_home_detail.*
|
import kotlinx.android.synthetic.main.fragment_home_detail.*
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -93,13 +94,13 @@ class HomeDetailFragment @Inject constructor(
|
||||||
unknownDevices.forEachIndexed { index, deviceInfo ->
|
unknownDevices.forEachIndexed { index, deviceInfo ->
|
||||||
Timber.v("## Detector - #$index deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}")
|
Timber.v("## Detector - #$index deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}")
|
||||||
}
|
}
|
||||||
|
val uid = "Newest_Device"
|
||||||
|
alertManager.cancelAlert(uid)
|
||||||
if (it.canCrossSign && unknownDevices.isNotEmpty()) {
|
if (it.canCrossSign && unknownDevices.isNotEmpty()) {
|
||||||
val newest = unknownDevices.first().second
|
val newest = unknownDevices.first().second
|
||||||
val user = unknownDevices.first().first
|
val user = unknownDevices.first().first
|
||||||
val uid = "ND_${newest.deviceId}"
|
|
||||||
alertManager.cancelAlert(uid)
|
|
||||||
alertManager.postVectorAlert(
|
alertManager.postVectorAlert(
|
||||||
VectorAlert(
|
VerificationVectorAlert(
|
||||||
uid = uid,
|
uid = uid,
|
||||||
title = getString(R.string.new_session),
|
title = getString(R.string.new_session),
|
||||||
description = getString(R.string.new_session_review),
|
description = getString(R.string.new_session_review),
|
||||||
|
|
|
@ -36,8 +36,7 @@ import im.vector.riotx.core.platform.VectorViewModel
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
|
||||||
data class UnknownDevicesState(
|
data class UnknownDevicesState(
|
||||||
val unknownSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
|
val unknownSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>> = Uninitialized,
|
||||||
val verifiedSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
|
|
||||||
val canCrossSign: Boolean = false
|
val canCrossSign: Boolean = false
|
||||||
) : MvRxState
|
) : MvRxState
|
||||||
|
|
||||||
|
@ -47,16 +46,21 @@ class UnknownDeviceDetectorSharedViewModel(session: Session, initialState: Unkno
|
||||||
session.rx().liveUserCryptoDevices(session.myUserId)
|
session.rx().liveUserCryptoDevices(session.myUserId)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.switchMap { deviceList ->
|
.switchMap { deviceList ->
|
||||||
|
// Timber.v("## Detector - ============================")
|
||||||
|
// Timber.v("## Detector - Crypto device update ${deviceList.map { "${it.deviceId} : ${it.isVerified}" }}")
|
||||||
singleBuilder<DevicesListResponse> {
|
singleBuilder<DevicesListResponse> {
|
||||||
session.cryptoService().getDevicesList(it)
|
session.cryptoService().getDevicesList(it)
|
||||||
NoOpCancellable
|
NoOpCancellable
|
||||||
}.map { resp ->
|
}.map { resp ->
|
||||||
|
// Timber.v("## Detector - Device Infos ${resp.devices?.map { "${it.deviceId} : lastSeen:${it.lastSeenTs}" }}")
|
||||||
resp.devices?.filter { info ->
|
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 }
|
}?.sortedByDescending { it.lastSeenTs }
|
||||||
?.map {
|
?.map {
|
||||||
session.getUser(it.user_id ?: "")?.toMatrixItem() to it
|
session.getUser(it.user_id ?: "")?.toMatrixItem() to it
|
||||||
}
|
} ?: emptyList()
|
||||||
}
|
}
|
||||||
.toObservable()
|
.toObservable()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue