[Subscribing] Blank display name
This commit is contained in:
parent
10974366fb
commit
a9b87de7a3
|
@ -0,0 +1 @@
|
|||
[Subscribing] Blank display name
|
|
@ -21,6 +21,7 @@ import android.net.Uri
|
|||
import androidx.lifecycle.LiveData
|
||||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.user.model.User
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.api.util.Optional
|
||||
|
||||
|
@ -118,4 +119,17 @@ interface ProfileService {
|
|||
* Remove a 3Pid from the Matrix account.
|
||||
*/
|
||||
suspend fun deleteThreePid(threePid: ThreePid)
|
||||
|
||||
/**
|
||||
* Return a User object from a userId
|
||||
*/
|
||||
suspend fun getProfileAsUser(userId: String): User {
|
||||
return getProfile(userId).let { dict ->
|
||||
User(
|
||||
userId = userId,
|
||||
displayName = dict[DISPLAY_NAME_KEY] as? String,
|
||||
avatarUrl = dict[AVATAR_URL_KEY] as? String
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.sync
|
|||
|
||||
import android.os.SystemClock
|
||||
import okhttp3.ResponseBody
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.logger.LoggerTag
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
|
||||
|
@ -104,7 +105,11 @@ internal class DefaultSyncTask @Inject constructor(
|
|||
val isInitialSync = token == null
|
||||
if (isInitialSync) {
|
||||
// We might want to get the user information in parallel too
|
||||
userStore.createOrUpdate(userId)
|
||||
val user = tryOrNull { session.getProfileAsUser(userId) }
|
||||
userStore.createOrUpdate(
|
||||
userId = userId,
|
||||
displayName = user?.displayName,
|
||||
avatarUrl = user?.avatarUrl)
|
||||
defaultSyncStatusService.startRoot(InitSyncStep.ImportingAccount, 100)
|
||||
}
|
||||
// Maybe refresh the homeserver capabilities data we know
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
|
|||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.profile.ProfileService
|
||||
import org.matrix.android.sdk.api.session.room.Room
|
||||
import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
|
@ -328,12 +327,12 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
|
|||
|
||||
private suspend fun fetchProfileInfo() {
|
||||
val result = runCatchingToAsync {
|
||||
session.getProfile(initialState.userId)
|
||||
session.getProfileAsUser(initialState.userId)
|
||||
.let {
|
||||
MatrixItem.UserItem(
|
||||
id = initialState.userId,
|
||||
displayName = it[ProfileService.DISPLAY_NAME_KEY] as? String,
|
||||
avatarUrl = it[ProfileService.AVATAR_URL_KEY] as? String
|
||||
displayName = it.displayName,
|
||||
avatarUrl = it.avatarUrl
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.matrix.android.sdk.api.session.Session
|
|||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceListener
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.profile.ProfileService
|
||||
import org.matrix.android.sdk.api.session.user.model.User
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
|
||||
|
@ -213,14 +212,10 @@ class UserListViewModel @AssistedInject constructor(
|
|||
ThreePidUser(email = search, user = null)
|
||||
} else {
|
||||
try {
|
||||
val json = session.getProfile(foundThreePid.matrixId)
|
||||
val user = tryOrNull { session.getProfileAsUser(foundThreePid.matrixId) } ?: User(foundThreePid.matrixId)
|
||||
ThreePidUser(
|
||||
email = search,
|
||||
user = User(
|
||||
userId = foundThreePid.matrixId,
|
||||
displayName = json[ProfileService.DISPLAY_NAME_KEY] as? String,
|
||||
avatarUrl = json[ProfileService.AVATAR_URL_KEY] as? String
|
||||
)
|
||||
user = user
|
||||
)
|
||||
} catch (failure: Throwable) {
|
||||
ThreePidUser(email = search, user = User(foundThreePid.matrixId))
|
||||
|
@ -240,11 +235,11 @@ class UserListViewModel @AssistedInject constructor(
|
|||
.searchUsersDirectory(search, 50, state.excludedUserIds.orEmpty())
|
||||
.sortedBy { it.toMatrixItem().firstLetterOfDisplayName() }
|
||||
val userProfile = if (MatrixPatterns.isUserId(search)) {
|
||||
val json = tryOrNull { session.getProfile(search) }
|
||||
val user = tryOrNull { session.getProfileAsUser(search) }
|
||||
User(
|
||||
userId = search,
|
||||
displayName = json?.get(ProfileService.DISPLAY_NAME_KEY) as? String,
|
||||
avatarUrl = json?.get(ProfileService.AVATAR_URL_KEY) as? String
|
||||
displayName = user?.displayName,
|
||||
avatarUrl = user?.avatarUrl
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
Loading…
Reference in New Issue