Enhance AI Agent Profile Interaction
This commit introduces several enhancements to how AI agent profiles are displayed and interacted with:
**Profile Display:**
- **AI Account Distinction:** Profile pages now differentiate between regular user accounts and AI agent accounts.
- AI agent profiles will not display the "Agents" tab in their profile.
- The profile header height is adjusted for AI accounts.
- **Navigation Parameter:** An `isAiAccount` boolean parameter is added to the `AccountProfile` navigation route to indicate if the profile being viewed belongs to an AI.
**Interaction & Navigation:**
- **Avatar Click Navigation:**
- Clicking an AI agent's avatar in various lists (Hot Agents, My Agents, User Agents Row, User Agents List) now navigates to the agent's dedicated profile page.
- When navigating to an agent's profile from an agent list, `isAiAccount` is set to `true`.
- **Chat Initiation:** Clicking the chat button on AI agent cards in the "Agent" tab (both Hot and My Agents) now correctly initiates a chat with the respective AI.
- **ViewModel Updates:**
- `AgentViewModel`, `MineAgentViewModel`, and `HotAgentViewModel` now include a `goToProfile` function to handle navigation to agent profiles, correctly passing the `isAiAccount` flag.
**Code Refinements:**
- Click handlers for agent avatars and chat buttons are now wrapped with `DebounceUtils.simpleDebounceClick` to prevent multiple rapid clicks.
- The `UserContentPageIndicator` now conditionally hides the "Agent" tab based on the `isAiAccount` status.
- `UserAgentsRow` and `UserAgentsList` now accept an `onAvatarClick` callback for navigating to agent profiles.
- `AgentItem` (used in `UserAgentsRow`) and `UserAgentCard` (used in `UserAgentsList`) now handle avatar clicks.
- The general `Agent` composable (used in `AiPostComposable`) now also supports an `onAvatarClick` callback.
This commit is contained in:
@@ -91,6 +91,8 @@ import androidx.paging.LoadState
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.ConstVars
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
@@ -194,27 +196,45 @@ fun PostScreen(
|
||||
},
|
||||
isSelf = AppState.UserId?.toLong() == contextComment?.author,
|
||||
onLikeClick = {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
}
|
||||
contextComment?.let {
|
||||
viewModel.viewModelScope.launch {
|
||||
if (it.liked) {
|
||||
viewModel.unlikeComment(it.id)
|
||||
} else {
|
||||
viewModel.likeComment(it.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
}
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
}
|
||||
contextComment?.let {
|
||||
viewModel.viewModelScope.launch {
|
||||
if (it.liked) {
|
||||
viewModel.unlikeComment(it.id)
|
||||
} else {
|
||||
viewModel.likeComment(it.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
onReplyClick = {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
replyComment = contextComment
|
||||
showCommentModal = true
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
}
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
commentModalState.hide()
|
||||
showCommentMenu = false
|
||||
replyComment = contextComment
|
||||
showCommentModal = true
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -293,24 +313,39 @@ fun PostScreen(
|
||||
if (!viewModel.isError) {
|
||||
PostBottomBar(
|
||||
onLikeClick = {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.liked == true) {
|
||||
viewModel.dislikeMoment()
|
||||
} else {
|
||||
viewModel.likeMoment()
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.liked == true) {
|
||||
viewModel.dislikeMoment()
|
||||
} else {
|
||||
viewModel.likeMoment()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onCreateCommentClick = {
|
||||
replyComment = null
|
||||
showCommentModal = true
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
replyComment = null
|
||||
showCommentModal = true
|
||||
}
|
||||
},
|
||||
onFavoriteClick = {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.isFavorite == true) {
|
||||
viewModel.unfavoriteMoment()
|
||||
} else {
|
||||
viewModel.favoriteMoment()
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.isFavorite == true) {
|
||||
viewModel.unfavoriteMoment()
|
||||
} else {
|
||||
viewModel.favoriteMoment()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -356,11 +391,16 @@ fun PostScreen(
|
||||
userId = viewModel.moment?.authorId,
|
||||
isFollowing = viewModel.moment?.followStatus == true,
|
||||
onFollowClick = {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.followStatus == true) {
|
||||
viewModel.unfollowUser()
|
||||
} else {
|
||||
viewModel.followUser()
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
if (viewModel.moment?.followStatus == true) {
|
||||
viewModel.unfollowUser()
|
||||
} else {
|
||||
viewModel.followUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -370,7 +410,12 @@ fun PostScreen(
|
||||
}
|
||||
},
|
||||
onReportClick = {
|
||||
showReportDialog = true
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.REPORT_CONTENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
showReportDialog = true
|
||||
}
|
||||
}
|
||||
)
|
||||
LazyColumn(
|
||||
@@ -430,8 +475,13 @@ fun PostScreen(
|
||||
contextComment = comment
|
||||
},
|
||||
onReply = { parentComment, _, _, _ ->
|
||||
replyComment = parentComment
|
||||
showCommentModal = true
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
replyComment = parentComment
|
||||
showCommentModal = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -454,6 +504,7 @@ fun CommentContent(
|
||||
onReply: (CommentEntity, Long?, String?, String?) -> Unit
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val navController = LocalNavController.current
|
||||
|
||||
val commentsPagging = viewModel.commentsFlow.collectAsLazyPagingItems()
|
||||
val addedTopLevelComment = viewModel.addedCommentList.filter {
|
||||
@@ -468,11 +519,16 @@ fun CommentContent(
|
||||
CommentItem(
|
||||
it,
|
||||
onLike = { comment ->
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -480,12 +536,17 @@ fun CommentContent(
|
||||
onLongClick(comment)
|
||||
},
|
||||
onReply = { parentComment, _, _, _ ->
|
||||
onReply(
|
||||
parentComment,
|
||||
parentComment.author,
|
||||
parentComment.name,
|
||||
parentComment.avatar
|
||||
)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
onReply(
|
||||
parentComment,
|
||||
parentComment.author,
|
||||
parentComment.name,
|
||||
parentComment.avatar
|
||||
)
|
||||
}
|
||||
},
|
||||
onLoadMoreSubComments = {
|
||||
viewModel.viewModelScope.launch {
|
||||
@@ -512,11 +573,16 @@ fun CommentContent(
|
||||
CommentItem(
|
||||
item,
|
||||
onLike = { comment ->
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -560,11 +626,16 @@ fun CommentContent(
|
||||
CommentItem(
|
||||
item,
|
||||
onLike = { comment ->
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
viewModel.viewModelScope.launch {
|
||||
if (comment.liked) {
|
||||
viewModel.unlikeComment(comment.id)
|
||||
} else {
|
||||
viewModel.likeComment(comment.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -572,12 +643,17 @@ fun CommentContent(
|
||||
onLongClick(comment)
|
||||
},
|
||||
onReply = { parentComment, _, _, _ ->
|
||||
onReply(
|
||||
parentComment,
|
||||
parentComment.author,
|
||||
parentComment.name,
|
||||
parentComment.avatar
|
||||
)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
onReply(
|
||||
parentComment,
|
||||
parentComment.author,
|
||||
parentComment.name,
|
||||
parentComment.avatar
|
||||
)
|
||||
}
|
||||
},
|
||||
onLoadMoreSubComments = {
|
||||
viewModel.viewModelScope.launch {
|
||||
|
||||
Reference in New Issue
Block a user