Refactor: 优化关注列表和代码逻辑

本次提交主要包含以下更改:

- **关注/粉丝列表逻辑修正**:修复了在 `FollowerListViewModel` 和 `FollowingListViewModel` 中 `followerId` 和 `followingId` 属性赋值错误的问题,确保正确加载关注和粉丝列表。
- **分页大小调整**:将 `BaseFollowModel` 中分页加载的 `pageSize` 从 5 调整为 20,以提高用户体验。
- **个人资料页智能体展示**:
    - 在 `AccountProfileV2` 和 `AccountProfileViewModel` 中增加了对用户智能体列表的加载和展示逻辑。
    - 修复了 `MyProfileViewModel` 中加载当前用户智能体时 `authorId` 传递错误的问题。
    - 优化了 `UserAgentsRow` 和 `UserAgentsViewModel` 的逻辑,确保正确加载和显示用户智能体,并在用户切换时清理旧数据。
- **代码清理**:移除了部分冗余的 `println` 调试信息。
- **Agent创建流程优化**:在 `AddAgentViewModel` 和 `AgentImageCropScreen` 中,确保在已有裁剪图片时直接使用,避免重复裁剪。
This commit is contained in:
2025-08-31 23:50:52 +08:00
parent 281169cfcb
commit 2907e7f9a6
15 changed files with 35 additions and 47 deletions

View File

@@ -27,6 +27,7 @@ fun AccountProfileV2(id: String){
}
ProfileV3(
moments = model.moments,
agents = model.agents,
profile = model.profile,
isSelf = isSelf,
postCount = model.momentLoader.total,
@@ -53,6 +54,9 @@ fun AccountProfileV2(id: String){
model.followUser(id)
}
}
},
onAgentClick = { agent ->
// TODO: 处理Agent点击事件导航到聊天页面
}
)
}

View File

@@ -10,6 +10,9 @@ import com.aiosman.ravenow.data.AccountService
import com.aiosman.ravenow.data.AccountServiceImpl
import com.aiosman.ravenow.data.UserServiceImpl
import com.aiosman.ravenow.entity.AccountProfileEntity
import com.aiosman.ravenow.entity.AgentEntity
import com.aiosman.ravenow.entity.AgentLoader
import com.aiosman.ravenow.entity.AgentLoaderExtraArgs
import com.aiosman.ravenow.entity.MomentEntity
import com.aiosman.ravenow.entity.MomentLoader
import com.aiosman.ravenow.entity.MomentLoaderExtraArgs
@@ -32,6 +35,13 @@ class AccountProfileViewModel : ViewModel() {
}
}
var moments by mutableStateOf<List<MomentEntity>>(listOf())
var agentLoader = AgentLoader().apply {
onListChanged = {
agents = it
}
}
var agents by mutableStateOf<List<AgentEntity>>(listOf())
init {
EventBus.getDefault().register(this)
}
@@ -54,6 +64,12 @@ class AccountProfileViewModel : ViewModel() {
profile?.let {
try {
momentLoader.loadData(MomentLoaderExtraArgs(authorId = it.id))
// 根据是否是当前用户来决定传递authorId
// 如果是当前用户传递null以调用getMyAgent()
// 如果是其他用户传递用户ID以调用getAgent(authorId)
val isSelf = it.id.toString() == com.aiosman.ravenow.AppState.UserId.toString()
val authorId = if (isSelf) null else it.id
agentLoader.loadData(AgentLoaderExtraArgs(authorId = authorId))
} catch (e: Exception) {
e.printStackTrace()
}