package com.aiosman.ravenow.ui.index.tabs.profile

import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext
import com.aiosman.ravenow.LocalNavController
import com.aiosman.ravenow.ui.navigateToPost

@Composable
fun ProfileWrap(

) {
    val context = LocalContext.current
    val navController = LocalNavController.current
    LaunchedEffect(Unit) {
        MyProfileViewModel.loadProfile()
    }
    ProfileV3(
        isMain = true,
        isAiAccount = MyProfileViewModel.profile?.aiAccount == true, // 传入AI账户判断
        postCount = MyProfileViewModel.momentLoader.total,
        onUpdateBanner = { uri, file, context ->
            MyProfileViewModel.updateUserProfileBanner(uri, file, context)
        },
        onLogout = {
            MyProfileViewModel.logout(context)
        },
        profile = MyProfileViewModel.profile,
        moments = MyProfileViewModel.moments,
        agents = MyProfileViewModel.agents,
        onLoadMore = {
            Log.d("ProfileWrap", "onLoadMore被调用")
            MyProfileViewModel.loadMoreMoment()
        },
        onLike = { moments ->
            MyProfileViewModel.likeMoment(moments)
        },
        onComment = {
            navController.navigateToPost(it.id)
        },
        onAgentClick = { agent ->
            // TODO: 处理Agent点击事件，导航到聊天页面
        }
    )
}