更新个人资料同时更新聊天个人信息

This commit is contained in:
2024-11-30 22:24:28 +08:00
parent 3a68a51f3c
commit 6c19f83cfb
5 changed files with 35 additions and 3 deletions

View File

@@ -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,14 +23,21 @@ 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 {
val file = File(context.cacheDir, "avatar.jpg")