Code review fixes.

This commit is contained in:
onurays 2020-05-06 11:20:08 +03:00
parent 3a0eed795a
commit c7c6cf70e4
6 changed files with 18 additions and 30 deletions

View File

@ -104,9 +104,11 @@ internal class DefaultUserService @Inject constructor(private val monarchy: Mona
.contains(UserEntityFields.USER_ID, filter)
.endGroup()
}
excludedUserIds?.let {
query.not().`in`(UserEntityFields.USER_ID, it.toTypedArray())
}
excludedUserIds
?.takeIf { it.isNotEmpty() }
?.let {
query.not().`in`(UserEntityFields.USER_ID, it.toTypedArray())
}
query.sort(UserEntityFields.DISPLAY_NAME)
}
return monarchy.findAllPagedWithChanges(realmDataSourceFactory, livePagedListBuilder)

View File

@ -26,7 +26,6 @@ import com.airbnb.mvrx.MvRx
import com.airbnb.mvrx.viewModel
import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.room.failure.CreateRoomFailure
import im.vector.riotx.R
import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.error.ErrorFormatter
@ -114,20 +113,16 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
private fun renderInviteFailure(error: Throwable) {
hideWaitingView()
if (error is CreateRoomFailure.CreatedWithTimeout) {
finish()
val message = if (error is Failure.ServerError && error.httpCode == HttpURLConnection.HTTP_INTERNAL_ERROR /*500*/) {
// This error happen if the invited userId does not exist.
getString(R.string.invite_users_to_room_failure)
} else {
val message = if (error is Failure.ServerError && error.httpCode == HttpURLConnection.HTTP_INTERNAL_ERROR /*500*/) {
// This error happen if the invited userId does not exist.
getString(R.string.invite_users_to_room_failure)
} else {
errorFormatter.toHumanReadable(error)
}
AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton(R.string.ok, null)
.show()
errorFormatter.toHumanReadable(error)
}
AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton(R.string.ok, null)
.show()
}
private fun renderInvitationSuccess() = withState(viewModel) {

View File

@ -48,9 +48,7 @@ class KnownUsersFragment @Inject constructor(
override fun getLayoutResId() = R.layout.fragment_known_users
override fun getMenuRes() = withState(viewModel) {
return@withState it.menuResId ?: -1
}
override fun getMenuRes() = args.menuResId
private val viewModel: UserDirectoryViewModel by activityViewModel()
private lateinit var sharedActionViewModel: UserDirectorySharedActionViewModel

View File

@ -22,6 +22,6 @@ import kotlinx.android.parcel.Parcelize
@Parcelize
data class KnownUsersFragmentArgs(
val title: String,
val menuResId: Int? = null,
val menuResId: Int,
val excludedUserIds: Set<String>? = null
) : Parcelable

View File

@ -19,6 +19,6 @@ package im.vector.riotx.features.userdirectory
import im.vector.riotx.core.platform.VectorViewEvents
/**
* Transient events for create direct room screen
* Transient events for invite users to room screen
*/
sealed class UserDirectoryViewEvents : VectorViewEvents

View File

@ -30,15 +30,8 @@ data class UserDirectoryViewState(
val selectedUsers: Set<User> = emptySet(),
val createAndInviteState: Async<String> = Uninitialized,
val directorySearchTerm: String = "",
val filterKnownUsersValue: Option<String> = Option.empty(),
val title: String,
val menuResId: Int?
val filterKnownUsersValue: Option<String> = Option.empty()
) : MvRxState {
constructor(args: KnownUsersFragmentArgs) : this(title = args.title, menuResId = args.menuResId, excludedUserIds = args.excludedUserIds)
enum class DisplayMode {
KNOWN_USERS,
DIRECTORY_USERS
}
constructor(args: KnownUsersFragmentArgs) : this(excludedUserIds = args.excludedUserIds)
}