Skip to content

Commit

Permalink
Add user completion for matrix ids (#8271)
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle authored Mar 30, 2023
1 parent 1227f04 commit ed121c0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/8217.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add user completion for matrix ids
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ed121c0

Please sign in to comment.