package com.adealink.weparty.gift

import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import com.adealink.frame.base.Rlt
import com.adealink.frame.spi.RegisterService
import com.adealink.weparty.gift.manager.giftManager
import com.adealink.weparty.gift.viewmodel.GiftViewModel
import com.adealink.weparty.gift.viewmodel.GiftViewModelFactory
import com.adealink.weparty.module.gift.IGiftService
import com.adealink.weparty.module.gift.data.GiftInfo
import com.adealink.weparty.module.gift.data.GiftResource
import com.adealink.weparty.module.gift.viewmodel.IGiftViewModel

@RegisterService(value = IGiftService::class)
class GiftServiceImpl : IGiftService {
    override fun getGiftViewModel(owner: ViewModelStoreOwner): IGiftViewModel {
        return ViewModelProvider(owner, GiftViewModelFactory())[GiftViewModel::class.java]
    }

    override fun getGiftResource(forceNet: Boolean) {
        giftManager.getGiftResource(forceNet)
    }

    override fun getGifts(roomId: String, forceNet: Boolean) {
        giftManager.getGifts(roomId, forceNet)
    }

    override fun getGiftResource(resId: String): GiftResource? {
        return giftManager.getGiftResource(resId)
    }

    override suspend fun getGift(roomId: String, giftId: String): Rlt<GiftInfo?> {
        return giftManager.getGift(roomId,giftId)
    }

    override suspend fun getGifts(roomId: String, giftIds: Set<String>): Rlt<List<GiftInfo>> {
        return giftManager.getGifts(roomId, giftIds)
    }

    override fun getService(): IGiftService {
        return this
    }

    override fun onLogout() {
    }


}