Some formatting and cleanup

This commit is contained in:
Benoit Marty 2021-04-20 17:33:57 +02:00
parent f086f0e083
commit 820531120a
2 changed files with 17 additions and 10 deletions

View file

@ -112,7 +112,10 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
private fun PermalinkData.RoomLink.getRoomId(): Single<Optional<String>> {
val session = activeSessionHolder.getSafeActiveSession()
return if (isRoomAlias && session != null) {
session.rx().getRoomIdByAlias(roomIdOrAlias, true).map { it.getOrNull()?.roomId.toOptional() }.subscribeOn(Schedulers.io())
session.rx()
.getRoomIdByAlias(roomIdOrAlias, true)
.map { it.getOrNull()?.roomId.toOptional() }
.subscribeOn(Schedulers.io())
} else {
Single.just(Optional.from(roomIdOrAlias))
}

View file

@ -144,15 +144,19 @@ class UserListViewModel @AssistedInject constructor(@Assisted initialState: User
}
.onErrorReturn { Optional.empty() }
Single.zip(searchObservable, profileObservable, { searchResults, optionalProfile ->
val profile = optionalProfile.getOrNull() ?: return@zip searchResults
val searchContainsProfile = searchResults.indexOfFirst { it.userId == profile.userId } != -1
if (searchContainsProfile) {
searchResults
} else {
listOf(profile) + searchResults
}
})
Single.zip(
searchObservable,
profileObservable,
{ searchResults, optionalProfile ->
val profile = optionalProfile.getOrNull() ?: return@zip searchResults
val searchContainsProfile = searchResults.any { it.userId == profile.userId }
if (searchContainsProfile) {
searchResults
} else {
listOf(profile) + searchResults
}
}
)
}
}
stream.toAsync {