Sort the room member list and display member roles (#2412)

* Sort the room member list and display member roles

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-02-19 16:03:36 +01:00 committed by GitHub
parent 4f4a73fe64
commit 0a6f00e9df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 235 additions and 33 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.ui.room
import io.element.android.libraries.matrix.api.room.RoomMember
/**
* Returns the name value to use when sorting room members.
*
* If the display name is not null and not empty, it is returned.
* Otherwise, the user ID is returned without the initial "@".
*/
fun RoomMember.sortingName(): String {
return displayName?.takeIf { it.isNotEmpty() } ?: userId.value.drop(1)
}