更新个人资料同时更新聊天个人信息
This commit is contained in:
@@ -103,7 +103,7 @@ object AppState {
|
||||
val profile = accountService.getMyAccountProfile()
|
||||
val info = V2TIMUserFullInfo()
|
||||
info.setNickname(profile.nickName)
|
||||
info.faceUrl = profile.avatar
|
||||
info.faceUrl = profile.rawAvatar
|
||||
info.selfSignature = profile.bio
|
||||
return suspendCoroutine { continuation ->
|
||||
V2TIMManager.getInstance().setSelfInfo(info, object : V2TIMCallback {
|
||||
|
||||
@@ -72,7 +72,8 @@ data class AccountProfile(
|
||||
}
|
||||
null
|
||||
},
|
||||
trtcUserId = trtcUserId
|
||||
trtcUserId = trtcUserId,
|
||||
rawAvatar = avatar
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ data class AccountProfileEntity(
|
||||
val banner: String?,
|
||||
// trtcUserId
|
||||
val trtcUserId: String,
|
||||
val rawAvatar: String
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.aiosman.ravenow.data.AccountServiceImpl
|
||||
import com.aiosman.ravenow.data.UploadImage
|
||||
import com.aiosman.ravenow.entity.AccountProfileEntity
|
||||
import com.aiosman.ravenow.ui.index.tabs.profile.MyProfileViewModel
|
||||
import com.aiosman.ravenow.utils.TrtcHelper
|
||||
import java.io.File
|
||||
|
||||
object AccountEditViewModel : ViewModel() {
|
||||
@@ -22,13 +23,20 @@ object AccountEditViewModel : ViewModel() {
|
||||
var profile by mutableStateOf<AccountProfileEntity?>(null)
|
||||
var croppedBitmap by mutableStateOf<Bitmap?>(null)
|
||||
var isUpdating by mutableStateOf(false)
|
||||
suspend fun reloadProfile() {
|
||||
suspend fun reloadProfile(updateTrtcProfile:Boolean = false) {
|
||||
accountService.getMyAccountProfile().let {
|
||||
profile = it
|
||||
name = it.nickName
|
||||
bio = it.bio
|
||||
if (updateTrtcProfile) {
|
||||
TrtcHelper.updateTrtcProfile(
|
||||
it.nickName,
|
||||
it.rawAvatar
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
suspend fun updateUserProfile(context: Context) {
|
||||
val newAvatar = croppedBitmap?.let {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.aiosman.ravenow.utils
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMCallback
|
||||
import com.tencent.imsdk.v2.V2TIMManager
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
@@ -19,4 +21,24 @@ object TrtcHelper {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateTrtcProfile(
|
||||
avatar: String?,
|
||||
nickName: String?
|
||||
) {
|
||||
val info = V2TIMUserFullInfo()
|
||||
nickName?.let { info.setNickname(it) }
|
||||
avatar?.let { info.faceUrl = it }
|
||||
return suspendCoroutine { continuation ->
|
||||
V2TIMManager.getInstance().setSelfInfo(info, object : V2TIMCallback {
|
||||
override fun onError(code: Int, desc: String?) {
|
||||
continuation.resumeWith(Result.failure(Exception("Error $code: $desc")))
|
||||
}
|
||||
|
||||
override fun onSuccess() {
|
||||
continuation.resumeWith(Result.success(Unit))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user