package com.gh.gamecenter.home.custom.eventlistener

import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.home.custom.CustomPageViewModel
import com.gh.gamecenter.home.custom.tracker.SubjectTracker

class RecentMiniGameItemEventHelper(
    viewModel: CustomPageViewModel
) : CustomPageItemChildEventHelper(viewModel) {

    private val tracker = SubjectTracker(viewModel.pageLocation)

    fun navigateToGameDetailPage(position: Int, gameEntity: GameEntity) {
        viewModel.navigateToGameDetailPageByGame(_item, position, gameEntity)
        if (gameEntity.isQQMiniGame()) {
            tracker.trackQqGameRecentlyPlayedClick("游戏", gameEntity)
        } else {
            tracker.trackMiniGameClick(_item, gameEntity)
        }
    }

    fun navigateToLinkPage(link: LinkEntity) {
        tracker.trackQqGameRecentlyPlayedClick("更多", null)
        viewModel.navigateToLinkPage(_item, link, "", null)
    }
}