package com.adealink.weparty.profile.viewmodel

import androidx.lifecycle.MutableLiveData
import com.adealink.frame.base.Rlt
import com.adealink.frame.mvvm.viewmodel.BaseViewModel
import com.adealink.weparty.App
import com.adealink.weparty.module.room.data.RoomInfo
import com.adealink.weparty.profile.data.GetUserLiveRoomReq
import com.adealink.weparty.profile.datasource.remote.ProfileHttpService
import kotlinx.coroutines.launch

class ProfileRoomViewModel : BaseViewModel() {

    private val profileHttpService by lazy {
        App.instance.networkService.getHttpService(ProfileHttpService::class.java)
    }

    val userRoomInfoLD = MutableLiveData<Pair<String, RoomInfo?>>()
    fun getUserRoomStatus(uid: String) {
        viewModelScope.launch {
            val rlt = profileHttpService.getLiveRoomInfo(GetUserLiveRoomReq(uid))
            when (rlt) {
                is Rlt.Failed -> {

                }

                is Rlt.Success -> {
                    userRoomInfoLD.send(Pair(uid, rlt.data.data?.roomInfo))
                }
            }
        }
    }

}