package com.gamedog.vididin.main.fragments.home



import com.ama.core.architecture.appBase.vm.AppViewModel
import com.ama.core.architecture.page.RefreshRepository
import com.gamedog.vididin.beans.ResYoutubePlayList
import com.gamedog.vididin.beans.YoutubeVideo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject


@HiltViewModel
class YoutubeViewModel @Inject constructor(
    private val mRepository: YoutubeRepository,
) : AppViewModel<YoutubeUiState>(), RefreshRepositoryOwner {

    override val uiStateInitialValue: YoutubeUiState = YoutubeUiState()
    override val uiStateFlow: Flow<YoutubeUiState> = mRepository.dataListFlow.map { listData ->
        YoutubeUiState(playLists = listData)
    }

    override fun onRefreshRepository(): RefreshRepository<*> {
        TODO("Not yet implemented")
    }

    fun loadVideoPage() {
         mRepository.load()
    }
}

data class YoutubeUiState(
    val playLists: List<YoutubeVideo>? = null,
    val taskRestTime: Long = 0,
    val starState: Boolean = false,
)

