Rename userAvatarURLString to userAvatarUrl

This commit is contained in:
Benoit Marty 2024-01-19 15:59:50 +01:00
parent 603b10264b
commit 0e57fbf352
6 changed files with 9 additions and 9 deletions

View file

@ -122,7 +122,7 @@ class RoomListPresenterTests {
fun `present - should start with no user and then load user with error`() = runTest { fun `present - should start with no user and then load user with error`() = runTest {
val matrixClient = FakeMatrixClient( val matrixClient = FakeMatrixClient(
userDisplayName = Result.failure(AN_EXCEPTION), userDisplayName = Result.failure(AN_EXCEPTION),
userAvatarURLString = Result.failure(AN_EXCEPTION), userAvatarUrl = Result.failure(AN_EXCEPTION),
) )
val scope = CoroutineScope(coroutineContext + SupervisorJob()) val scope = CoroutineScope(coroutineContext + SupervisorJob())
val presenter = createRoomListPresenter(client = matrixClient, coroutineScope = scope) val presenter = createRoomListPresenter(client = matrixClient, coroutineScope = scope)

View file

@ -72,7 +72,7 @@ interface MatrixClient : Closeable {
*/ */
suspend fun logout(ignoreSdkError: Boolean): String? suspend fun logout(ignoreSdkError: Boolean): String?
suspend fun loadUserDisplayName(): Result<String> suspend fun loadUserDisplayName(): Result<String>
suspend fun loadUserAvatarURLString(): Result<String?> suspend fun loadUserAvatarUrl(): Result<String?>
suspend fun getAccountManagementUrl(action: AccountManagementAction?): Result<String?> suspend fun getAccountManagementUrl(action: AccountManagementAction?): Result<String?>
suspend fun uploadMedia(mimeType: String, data: ByteArray, progressCallback: ProgressCallback?): Result<String> suspend fun uploadMedia(mimeType: String, data: ByteArray, progressCallback: ProgressCallback?): Result<String>
fun roomMembershipObserver(): RoomMembershipObserver fun roomMembershipObserver(): RoomMembershipObserver

View file

@ -19,11 +19,11 @@ package io.element.android.libraries.matrix.api.user
import io.element.android.libraries.matrix.api.MatrixClient import io.element.android.libraries.matrix.api.MatrixClient
/** /**
* Get the current user, as [MatrixUser], using [MatrixClient.loadUserAvatarURLString] * Get the current user, as [MatrixUser], using [MatrixClient.loadUserAvatarUrl]
* and [MatrixClient.loadUserDisplayName]. * and [MatrixClient.loadUserDisplayName].
*/ */
suspend fun MatrixClient.getCurrentUser(): MatrixUser { suspend fun MatrixClient.getCurrentUser(): MatrixUser {
val userAvatarUrl = loadUserAvatarURLString().getOrNull() val userAvatarUrl = loadUserAvatarUrl().getOrNull()
val userDisplayName = loadUserDisplayName().getOrNull() val userDisplayName = loadUserDisplayName().getOrNull()
return MatrixUser( return MatrixUser(
userId = sessionId, userId = sessionId,

View file

@ -426,7 +426,7 @@ class RustMatrixClient(
} }
} }
override suspend fun loadUserAvatarURLString(): Result<String?> = withContext(sessionDispatcher) { override suspend fun loadUserAvatarUrl(): Result<String?> = withContext(sessionDispatcher) {
runCatching { runCatching {
client.avatarUrl() client.avatarUrl()
} }

View file

@ -48,7 +48,7 @@ import kotlinx.coroutines.delay
class FakeMatrixClient( class FakeMatrixClient(
override val sessionId: SessionId = A_SESSION_ID, override val sessionId: SessionId = A_SESSION_ID,
private val userDisplayName: Result<String> = Result.success(A_USER_NAME), private val userDisplayName: Result<String> = Result.success(A_USER_NAME),
private val userAvatarURLString: Result<String> = Result.success(AN_AVATAR_URL), private val userAvatarUrl: Result<String> = Result.success(AN_AVATAR_URL),
override val roomListService: RoomListService = FakeRoomListService(), override val roomListService: RoomListService = FakeRoomListService(),
override val mediaLoader: MatrixMediaLoader = FakeMediaLoader(), override val mediaLoader: MatrixMediaLoader = FakeMediaLoader(),
private val sessionVerificationService: FakeSessionVerificationService = FakeSessionVerificationService(), private val sessionVerificationService: FakeSessionVerificationService = FakeSessionVerificationService(),
@ -135,8 +135,8 @@ class FakeMatrixClient(
return userDisplayName return userDisplayName
} }
override suspend fun loadUserAvatarURLString(): Result<String?> { override suspend fun loadUserAvatarUrl(): Result<String?> {
return userAvatarURLString return userAvatarUrl
} }
override suspend fun getAccountManagementUrl(action: AccountManagementAction?): Result<String?> { override suspend fun getAccountManagementUrl(action: AccountManagementAction?): Result<String?> {

View file

@ -297,7 +297,7 @@ class DefaultNotificationDrawerManager @Inject constructor(
operation = { operation = {
// myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash // myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash
val myUserDisplayName = client.loadUserDisplayName().getOrNull() ?: sessionId.value val myUserDisplayName = client.loadUserDisplayName().getOrNull() ?: sessionId.value
val userAvatarUrl = client.loadUserAvatarURLString().getOrNull() val userAvatarUrl = client.loadUserAvatarUrl().getOrNull()
MatrixUser( MatrixUser(
userId = sessionId, userId = sessionId,
displayName = myUserDisplayName, displayName = myUserDisplayName,