package com.adealink.weparty.module.playmate

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.playmate.viewmodel.IPlaymateDetailViewModel
import com.adealink.weparty.module.playmate.viewmodel.IPlaymateViewModel

object PlaymateModule : BaseDynamicModule<IPlaymateService>(IPlaymateService::class),
    IPlaymateService {

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

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

    override fun emptyService(): IPlaymateService {
        return object : IPlaymateService {

            override fun getService(): IPlaymateService? {
                return null
            }

            override fun getPlaymateViewModel(owner: ViewModelStoreOwner): IPlaymateViewModel? {
                return null
            }

            override fun getPlaymateDetailViewModel(owner: ViewModelStoreOwner): IPlaymateDetailViewModel? {
                return null
            }

            override fun reportWelcomeReply(uid: String) {
            }

            override fun reportUserPushChat(uid: String) {
            }

            override suspend fun isUserPushChatAvailable(uid: String): Rlt<Boolean> {
                return Rlt.Failed(AABModuleNotInitError())
            }

            override fun onLogout() {
            }
        }
    }

    override fun getPlaymateViewModel(owner: ViewModelStoreOwner): IPlaymateViewModel? {
        return getService().getPlaymateViewModel(owner)
    }

    override fun getPlaymateDetailViewModel(owner: ViewModelStoreOwner): IPlaymateDetailViewModel? {
        return getService().getPlaymateDetailViewModel(owner)
    }

    override fun reportWelcomeReply(uid: String) {
        getService().reportWelcomeReply(uid)
    }

    override fun reportUserPushChat(uid: String) {
        getService().reportUserPushChat(uid)
    }

    override suspend fun isUserPushChatAvailable(uid: String): Rlt<Boolean> {
        return getService().isUserPushChatAvailable(uid)
    }

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