Add user completion for matrix ids (#8271)
This commit is contained in:
parent
1227f048bb
commit
ed121c051b
|
@ -0,0 +1 @@
|
|||
Add user completion for matrix ids
|
|
@ -30,7 +30,8 @@ data class RoomMemberQueryParams(
|
|||
val displayName: QueryStringValue,
|
||||
val memberships: List<Membership>,
|
||||
val userId: QueryStringValue,
|
||||
val excludeSelf: Boolean
|
||||
val excludeSelf: Boolean,
|
||||
val displayNameOrUserId: QueryStringValue,
|
||||
) {
|
||||
|
||||
class Builder {
|
||||
|
@ -39,12 +40,14 @@ data class RoomMemberQueryParams(
|
|||
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
|
||||
var memberships: List<Membership> = Membership.all()
|
||||
var excludeSelf: Boolean = false
|
||||
var displayNameOrUserId: QueryStringValue = QueryStringValue.NoCondition
|
||||
|
||||
fun build() = RoomMemberQueryParams(
|
||||
displayName = displayName,
|
||||
memberships = memberships,
|
||||
userId = userId,
|
||||
excludeSelf = excludeSelf
|
||||
excludeSelf = excludeSelf,
|
||||
displayNameOrUserId = displayNameOrUserId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
package org.matrix.android.sdk.internal.session.room.membership
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import com.otaliastudios.opengl.core.use
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmQuery
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.room.members.MembershipService
|
||||
|
@ -58,7 +57,6 @@ internal class DefaultMembershipService @AssistedInject constructor(
|
|||
private val cryptoService: CryptoService,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
private val matrixConfiguration: MatrixConfiguration,
|
||||
private val queryStringValueProcessor: QueryStringValueProcessor
|
||||
) : MembershipService {
|
||||
|
||||
|
@ -120,6 +118,13 @@ internal class DefaultMembershipService @AssistedInject constructor(
|
|||
if (queryParams.excludeSelf) {
|
||||
notEqualTo(RoomMemberSummaryEntityFields.USER_ID, userId)
|
||||
}
|
||||
if (queryParams.displayNameOrUserId != QueryStringValue.NoCondition) {
|
||||
beginGroup()
|
||||
process(RoomMemberSummaryEntityFields.USER_ID, queryParams.displayNameOrUserId)
|
||||
or()
|
||||
process(RoomMemberSummaryEntityFields.DISPLAY_NAME, queryParams.displayNameOrUserId)
|
||||
endGroup()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ class AutocompleteMemberController @Inject constructor(private val context: Cont
|
|||
roomMember.roomMemberSummary.let { user ->
|
||||
id(user.userId)
|
||||
matrixItem(user.toMatrixItem())
|
||||
subName(user.userId)
|
||||
avatarRenderer(host.avatarRenderer)
|
||||
clickListener { host.listener?.onItemClick(roomMember) }
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ class AutocompleteMemberPresenter @AssistedInject constructor(
|
|||
* ========================================================================================== */
|
||||
|
||||
private fun createQueryParams(query: CharSequence?) = roomMemberQueryParams {
|
||||
displayName = if (query.isNullOrBlank()) {
|
||||
QueryStringValue.IsNotEmpty
|
||||
displayNameOrUserId = if (query.isNullOrBlank()) {
|
||||
QueryStringValue.NoCondition
|
||||
} else {
|
||||
QueryStringValue.Contains(query.toString(), QueryStringValue.Case.INSENSITIVE)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue