package com.adealink.weparty.module.gift

import androidx.lifecycle.ViewModelStoreOwner
import com.adealink.frame.aab.BaseDynamicModule
import com.adealink.frame.aab.constant.AABModuleNotInitError
import com.adealink.frame.base.Rlt
import com.adealink.weparty.R
import com.adealink.weparty.module.gift.data.GiftInfo
import com.adealink.weparty.module.gift.data.GiftResource
import com.adealink.weparty.module.gift.viewmodel.IGiftViewModel

object GiftModule : BaseDynamicModule<IGiftService>(IGiftService::class), IGiftService {

    override val moduleNameResId: Int
        get() = R.string.module_gift

    override val featureName: String
        get() = "gift"

    override fun emptyService(): IGiftService {
        return object : IGiftService {
            override fun getService(): IGiftService? {
                return null
            }

            override fun getGiftViewModel(owner: ViewModelStoreOwner): IGiftViewModel? {
                return null
            }

            override fun getGiftResource(forceNet: Boolean) {
            }

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

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

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

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

            override fun onLogout() {
            }
        }
    }

    override fun getGiftViewModel(owner: ViewModelStoreOwner): IGiftViewModel? {
        return getService().getGiftViewModel(owner)
    }

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

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

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

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

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

    override fun onLogout() {
        getService().onLogout()
    }


}