Ai和用户类型分组验证
This commit is contained in:
@@ -93,10 +93,10 @@ fun ChatAiScreen(userId: String) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
var goToNewCount by remember { mutableStateOf(0) }
|
||||
val viewModel = viewModel<ChatAiViewModel>(
|
||||
key = "ChatViewModel_$userId",
|
||||
key = "ChatAiViewModel_$userId",
|
||||
factory = object : ViewModelProvider.Factory {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return ChatViewModel(userId) as T
|
||||
return ChatAiViewModel(userId) as T
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -254,7 +254,7 @@ fun ChatAiScreen(userId: String) {
|
||||
AppColors.decentBackground)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
ChatInput(
|
||||
ChatAiInput(
|
||||
onSendImage = {
|
||||
it?.let {
|
||||
viewModel.sendImageMessage(it, context)
|
||||
@@ -298,7 +298,7 @@ fun ChatAiScreen(userId: String) {
|
||||
)
|
||||
}
|
||||
|
||||
ChatItem(item = item, viewModel.myProfile?.trtcUserId!!)
|
||||
ChatAiItem(item = item, viewModel.myProfile?.trtcUserId!!)
|
||||
|
||||
|
||||
}
|
||||
@@ -593,24 +593,6 @@ fun ChatAiInput(
|
||||
)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.rider_pro_camera),
|
||||
contentDescription = "Emoji",
|
||||
modifier = Modifier
|
||||
.size(30.dp)
|
||||
.noRippleClickable {
|
||||
imagePickUpLauncher.launch(
|
||||
Intent.createChooser(
|
||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||
type = "image/*"
|
||||
},
|
||||
"Select Image"
|
||||
)
|
||||
)
|
||||
},
|
||||
tint = appColors.chatActionColor
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Crossfade(
|
||||
targetState = text.isNotEmpty(), animationSpec = tween(500),
|
||||
|
||||
@@ -15,6 +15,9 @@ import com.aiosman.ravenow.data.AccountService
|
||||
import com.aiosman.ravenow.data.AccountServiceImpl
|
||||
import com.aiosman.ravenow.data.UserService
|
||||
import com.aiosman.ravenow.data.UserServiceImpl
|
||||
import com.aiosman.ravenow.data.api.ApiClient
|
||||
import com.aiosman.ravenow.data.api.SendChatAiRequestBody
|
||||
import com.aiosman.ravenow.data.api.SingleChatRequestBody
|
||||
import com.aiosman.ravenow.entity.AccountProfileEntity
|
||||
import com.aiosman.ravenow.entity.ChatItem
|
||||
import com.aiosman.ravenow.entity.ChatNotification
|
||||
@@ -147,6 +150,7 @@ class ChatAiViewModel(
|
||||
|
||||
override fun onSuccess(p0: V2TIMMessage?) {
|
||||
Log.d("ChatViewModel", "send message success")
|
||||
sendChatAiMessage(myProfile?.trtcUserId!!,userProfile?.trtcUserId!!, message)
|
||||
val chatItem = ChatItem.convertToChatItem(p0!!, context, avatar = myProfile?.avatar)
|
||||
chatItem?.let {
|
||||
chatData = listOf(it) + chatData
|
||||
@@ -250,6 +254,16 @@ class ChatAiViewModel(
|
||||
}
|
||||
)
|
||||
}
|
||||
fun sendChatAiMessage(
|
||||
fromTrtcUserId: String,
|
||||
toTrtcUserId: String,
|
||||
message: String,
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
val response = ApiClient.api.sendChatAiMessage(SendChatAiRequestBody(fromTrtcUserId = fromTrtcUserId,toTrtcUserId = toTrtcUserId,message = message))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun getDisplayChatList(): List<ChatItem> {
|
||||
val list = chatData
|
||||
|
||||
Reference in New Issue
Block a user