package com.renrenliao.im.viewmodel

import com.renrenliao.im.base.BaseViewModel
import com.renrenliao.im.http.checkError
import com.renrenliao.im.http.checkSuccess
import com.renrenliao.im.model.repository.RemoteDataSource
import com.renrenliao.im.utils.LogUtils
import com.renrenliao.im.utils.MapUtils
import com.renrenliao.im.utils.RingToast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 **@ClassName FriendCircleViewModel
 **@Description
 **@Author gan
 **@Date 2022/6/15 15:15
 **/
class FriendCircleViewModel(private val remoteDataSource: RemoteDataSource) : BaseViewModel() {

    fun getCircleData(pageIndex:Int,pageSize:Int){
        var map = HashMap<String,String>()
        map["pageIndex"] = pageIndex.toString()
        map["pageSize"] = pageSize.toString()
        map = MapUtils.getComParam(map)
        launchUI({
            val result = withContext(Dispatchers.IO){
                remoteDataSource.getFriendCircle(map)
            }
            result.checkSuccess {
                LogUtils.error(it)
            }

        },isShowToast = true)
    }
}