mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
parent
4d207e6acd
commit
3163bc8b80
2 changed files with 15 additions and 3 deletions
|
@ -35,6 +35,7 @@ Bugfix 🐛:
|
|||
- Local echo are not updated in timeline (for failed & encrypted states)
|
||||
- Render image event even if thumbnail_info does not have mimetype defined (#1209)
|
||||
- Fix issue with media path (#1227)
|
||||
- Add user to direct chat by user id (#1065)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.airbnb.mvrx.Fail
|
|||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.matrix.android.api.MatrixPatterns
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.user.model.User
|
||||
import im.vector.matrix.android.api.util.toMatrixItem
|
||||
|
@ -56,15 +57,25 @@ class DirectoryUsersController @Inject constructor(private val session: Session,
|
|||
override fun buildModels() {
|
||||
val currentState = state ?: return
|
||||
val hasSearch = currentState.directorySearchTerm.isNotBlank()
|
||||
val asyncUsers = currentState.directoryUsers
|
||||
when (asyncUsers) {
|
||||
when (val asyncUsers = currentState.directoryUsers) {
|
||||
is Uninitialized -> renderEmptyState(false)
|
||||
is Loading -> renderLoading()
|
||||
is Success -> renderSuccess(asyncUsers(), currentState.selectedUsers.map { it.userId }, hasSearch)
|
||||
is Success -> renderSuccess(getAsyncUsers(currentState), currentState.selectedUsers.map { it.userId }, hasSearch)
|
||||
is Fail -> renderFailure(asyncUsers.error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAsyncUsers(currentState: CreateDirectRoomViewState): List<User> {
|
||||
return currentState
|
||||
.directoryUsers()
|
||||
?.toMutableList()
|
||||
?.apply {
|
||||
currentState.directorySearchTerm
|
||||
.takeIf { MatrixPatterns.isUserId(it) }
|
||||
?.let { add(User(it)) }
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
private fun renderLoading() {
|
||||
loadingItem {
|
||||
id("loading")
|
||||
|
|
Loading…
Reference in a new issue