更新聊天头像逻辑
This commit is contained in:
@@ -183,6 +183,14 @@ fun ChatScreen(userId: String) {
|
||||
AppColors.text)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
CustomAsyncImage(
|
||||
imageUrl = viewModel.userProfile?.avatar ?: "",
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.clip(RoundedCornerShape(40.dp)),
|
||||
contentDescription = "avatar"
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = viewModel.userProfile?.nickName ?: "",
|
||||
modifier = Modifier.weight(1f),
|
||||
|
||||
@@ -66,7 +66,7 @@ class ChatViewModel(
|
||||
override fun onRecvNewMessage(msg: V2TIMMessage?) {
|
||||
super.onRecvNewMessage(msg)
|
||||
msg?.let {
|
||||
val chatItem = ChatItem.convertToChatItem(msg, context)
|
||||
val chatItem = ChatItem.convertToChatItem(msg, context, avatar = userProfile?.avatar)
|
||||
chatItem?.let {
|
||||
chatData = listOf(it) + chatData
|
||||
goToNew = true
|
||||
@@ -109,7 +109,11 @@ class ChatViewModel(
|
||||
object : V2TIMValueCallback<List<V2TIMMessage>> {
|
||||
override fun onSuccess(p0: List<V2TIMMessage>?) {
|
||||
chatData = chatData + (p0 ?: emptyList()).map {
|
||||
ChatItem.convertToChatItem(it, context)
|
||||
var avatar = userProfile?.avatar
|
||||
if (it.isSelf) {
|
||||
avatar = myProfile?.avatar
|
||||
}
|
||||
ChatItem.convertToChatItem(it, context,avatar)
|
||||
}.filterNotNull()
|
||||
if ((p0?.size ?: 0) < 20) {
|
||||
hasMore = false
|
||||
@@ -143,7 +147,7 @@ class ChatViewModel(
|
||||
|
||||
override fun onSuccess(p0: V2TIMMessage?) {
|
||||
Log.d("ChatViewModel", "send message success")
|
||||
val chatItem = ChatItem.convertToChatItem(p0!!, context)
|
||||
val chatItem = ChatItem.convertToChatItem(p0!!, context, avatar = myProfile?.avatar)
|
||||
chatItem?.let {
|
||||
chatData = listOf(it) + chatData
|
||||
goToNew = true
|
||||
@@ -176,7 +180,7 @@ class ChatViewModel(
|
||||
|
||||
override fun onSuccess(p0: V2TIMMessage?) {
|
||||
Log.d("ChatViewModel", "send image message success")
|
||||
val chatItem = ChatItem.convertToChatItem(p0!!, context)
|
||||
val chatItem = ChatItem.convertToChatItem(p0!!, context, avatar = myProfile?.avatar)
|
||||
chatItem?.let {
|
||||
chatData = listOf(it) + chatData
|
||||
goToNew = true
|
||||
@@ -227,7 +231,11 @@ class ChatViewModel(
|
||||
object : V2TIMValueCallback<List<V2TIMMessage>> {
|
||||
override fun onSuccess(p0: List<V2TIMMessage>?) {
|
||||
chatData = (p0 ?: emptyList()).mapNotNull {
|
||||
ChatItem.convertToChatItem(it, context)
|
||||
var avatar = userProfile?.avatar
|
||||
if (it.isSelf) {
|
||||
avatar = myProfile?.avatar
|
||||
}
|
||||
ChatItem.convertToChatItem(it, context,avatar)
|
||||
}
|
||||
if ((p0?.size ?: 0) < 20) {
|
||||
hasMore = false
|
||||
|
||||
@@ -12,12 +12,13 @@ import androidx.navigation.NavHostController
|
||||
import androidx.paging.PagingData
|
||||
import androidx.paging.map
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.ConstVars
|
||||
import com.aiosman.ravenow.data.AccountNotice
|
||||
import com.aiosman.ravenow.data.AccountService
|
||||
import com.aiosman.ravenow.entity.CommentEntity
|
||||
import com.aiosman.ravenow.data.AccountServiceImpl
|
||||
import com.aiosman.ravenow.data.UserService
|
||||
import com.aiosman.ravenow.data.UserServiceImpl
|
||||
import com.aiosman.ravenow.entity.CommentEntity
|
||||
import com.aiosman.ravenow.exp.formatChatTime
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.navigateToChat
|
||||
@@ -63,7 +64,7 @@ data class Conversation(
|
||||
nickname = msg.showName,
|
||||
lastMessage = msg.lastMessage?.textElem?.text ?: "",
|
||||
lastMessageTime = lastMessage.time.formatChatTime(context),
|
||||
avatar = msg.faceUrl,
|
||||
avatar = "${ConstVars.BASE_SERVER}${msg.faceUrl}",
|
||||
unreadCount = msg.unreadCount,
|
||||
trtcUserId = msg.userID,
|
||||
displayText = displayText,
|
||||
|
||||
Reference in New Issue
Block a user