Fix refreshing of sessions list when another session is logged out

Rx: use distinctUntilChanged() instead of distinct()
This commit is contained in:
Benoit Marty 2020-08-12 15:19:03 +02:00 committed by Benoit Marty
parent c9c787b11d
commit 7a2454d816
6 changed files with 14 additions and 13 deletions

View File

@ -11,6 +11,7 @@ Bugfix 🐛:
- Fix invisible toolbar (Status.im theme) (#1746) - Fix invisible toolbar (Status.im theme) (#1746)
- Fix relative date time formatting (#822) - Fix relative date time formatting (#822)
- Fix crash reported by RageShake - Fix crash reported by RageShake
- Fix refreshing of sessions list when another session is logged out
Translations 🗣: Translations 🗣:
- Add PlayStore description resources in the Triple-T format, to let Weblate handle them - Add PlayStore description resources in the Triple-T format, to let Weblate handle them

View File

@ -39,11 +39,8 @@ internal data class UploadSignatureQueryBuilder(
fun build(): Map<String, Map<String, @JvmSuppressWildcards Any>> { fun build(): Map<String, Map<String, @JvmSuppressWildcards Any>> {
val map = HashMap<String, HashMap<String, Any>>() val map = HashMap<String, HashMap<String, Any>>()
val usersList = ( val usersList = (deviceInfoList.map { it.userId } + signingKeyInfoList.map { it.userId })
deviceInfoList.map { it.userId } .distinct()
+ signingKeyInfoList
.map { it.userId }
).distinct()
usersList.forEach { userID -> usersList.forEach { userID ->
val userMap = HashMap<String, Any>() val userMap = HashMap<String, Any>()

View File

@ -66,7 +66,7 @@ class BootstrapAccountPasswordFragment @Inject constructor(
.disposeOnDestroyView() .disposeOnDestroyView()
bootstrapAccountPasswordEditText.textChanges() bootstrapAccountPasswordEditText.textChanges()
.distinct() .distinctUntilChanged()
.subscribe { .subscribe {
if (!it.isNullOrBlank()) { if (!it.isNullOrBlank()) {
bootstrapAccountPasswordTil.error = null bootstrapAccountPasswordTil.error = null

View File

@ -61,7 +61,7 @@ class ShortcutsHandler @Inject constructor(
return homeRoomListStore return homeRoomListStore
.observe() .observe()
.distinct() .distinctUntilChanged()
.observeOn(Schedulers.computation()) .observeOn(Schedulers.computation())
.subscribe { rooms -> .subscribe { rooms ->
val shortcuts = rooms val shortcuts = rooms

View File

@ -133,12 +133,13 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(@Assisted
} }
session.rx().liveUserCryptoDevices(session.myUserId) session.rx().liveUserCryptoDevices(session.myUserId)
.distinct() .distinctUntilChanged()
.throttleLast(5_000, TimeUnit.MILLISECONDS) .throttleLast(5_000, TimeUnit.MILLISECONDS)
.subscribe { .subscribe {
// If we have a new crypto device change, we might want to trigger refresh of device info // If we have a new crypto device change, we might want to trigger refresh of device info
session.cryptoService().fetchDevicesList(NoOpMatrixCallback()) session.cryptoService().fetchDevicesList(NoOpMatrixCallback())
}.disposeOnClear() }
.disposeOnClear()
// trigger a refresh of lastSeen / last Ip // trigger a refresh of lastSeen / last Ip
session.cryptoService().fetchDevicesList(NoOpMatrixCallback()) session.cryptoService().fetchDevicesList(NoOpMatrixCallback())

View File

@ -113,7 +113,7 @@ class DevicesViewModel @AssistedInject constructor(
} }
} }
) )
.distinct() .distinctUntilChanged()
.execute { async -> .execute { async ->
copy( copy(
devices = async devices = async
@ -137,12 +137,14 @@ class DevicesViewModel @AssistedInject constructor(
// } // }
session.rx().liveUserCryptoDevices(session.myUserId) session.rx().liveUserCryptoDevices(session.myUserId)
.distinct() .map { it.size }
.throttleLast(5_000, TimeUnit.MILLISECONDS) .distinctUntilChanged()
.throttleFirst(5_000, TimeUnit.MILLISECONDS)
.subscribe { .subscribe {
// If we have a new crypto device change, we might want to trigger refresh of device info // If we have a new crypto device change, we might want to trigger refresh of device info
session.cryptoService().fetchDevicesList(NoOpMatrixCallback()) session.cryptoService().fetchDevicesList(NoOpMatrixCallback())
}.disposeOnClear() }
.disposeOnClear()
// session.rx().liveUserCryptoDevices(session.myUserId) // session.rx().liveUserCryptoDevices(session.myUserId)
// .execute { // .execute {