Move and refactor MatrixUser (#381)
Move and refactor MatrixUser Instead of living in matrixui and having an AvatarData, this can reside in the matrix module and just have the URL. An extension method in matrixui can then provide the AvatarData when required. This removes some small duplication, and pushes the UI-specific information (i.e., what size of avatar is going to be rendered) further down the stack. It also aligns the field names with those used by the rust SDK (e.g. "displayName" instead of "userName").
This commit is contained in:
parent
271c66588a
commit
581c5ab2d2
51 changed files with 125 additions and 215 deletions
|
|
@ -26,7 +26,7 @@ import io.element.android.libraries.matrix.api.pusher.PushersService
|
|||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.RoomMembershipObserver
|
||||
import io.element.android.libraries.matrix.api.room.RoomSummaryDataSource
|
||||
import io.element.android.libraries.matrix.api.usersearch.MatrixSearchUserResults
|
||||
import io.element.android.libraries.matrix.api.user.MatrixSearchUserResults
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||
import java.io.Closeable
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package io.element.android.libraries.matrix.api.room
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
|
||||
data class RoomMember(
|
||||
val userId: UserId,
|
||||
|
|
@ -29,6 +30,12 @@ data class RoomMember(
|
|||
val isIgnored: Boolean,
|
||||
)
|
||||
|
||||
fun RoomMember.toMatrixUser() = MatrixUser(
|
||||
userId = userId,
|
||||
displayName = displayName,
|
||||
avatarUrl = avatarUrl,
|
||||
)
|
||||
|
||||
enum class RoomMembershipState {
|
||||
BAN, INVITE, JOIN, KNOCK, LEAVE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.usersearch
|
||||
package io.element.android.libraries.matrix.api.user
|
||||
|
||||
data class MatrixSearchUserResults(
|
||||
val results: List<MatrixUserProfile>,
|
||||
val results: List<MatrixUser>,
|
||||
val limited: Boolean,
|
||||
)
|
||||
|
|
@ -14,12 +14,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.usersearch
|
||||
package io.element.android.libraries.matrix.api.user
|
||||
|
||||
import android.os.Parcelable
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
data class MatrixUserProfile(
|
||||
@Parcelize
|
||||
data class MatrixUser(
|
||||
val userId: UserId,
|
||||
val displayName: String?,
|
||||
val avatarUrl: String?
|
||||
)
|
||||
val displayName: String? = null,
|
||||
val avatarUrl: String? = null
|
||||
) : Parcelable
|
||||
Loading…
Add table
Add a link
Reference in a new issue