package com.adealink.weparty.account.login.manager

import com.adealink.frame.util.AppUtil
import com.adealink.weparty.account.login.auth.AuthManager
import com.adealink.weparty.module.account.AccountLocalService
import com.adealink.weparty.module.account.AccountModule
import com.adealink.weparty.module.activity.ActivityModule
import com.adealink.weparty.module.call.CallModule
import com.adealink.weparty.module.gift.GiftModule
import com.adealink.weparty.module.im.IMModule
import com.adealink.weparty.module.joinus.JoinUsModule
import com.adealink.weparty.module.order.OrderModule
import com.adealink.weparty.module.playmate.PlaymateModule
import com.adealink.weparty.module.profile.ProfileModule
import com.adealink.weparty.module.room.RoomModule
import com.adealink.weparty.module.setting.SettingModule
import com.adealink.weparty.module.share.ShareModule
import com.adealink.weparty.module.wallet.WalletModule
import com.adealink.weparty.storage.AppPref

/**
 * 处理用户退出登录时的清理操作
 */
object LogoutCleaner {

    fun clean() {
        AppPref.refreshToken = ""
        AppPref.imToken = ""
        val authType = AccountLocalService.loginType
        AppUtil.currentActivity?.let {
            AuthManager(null).logout(authType, it)
        }
        AccountLocalService.loginType = ""

        //模块执行退登清理
        CallModule.onLogout()
        RoomModule.onLogout()
        OrderModule.onLogout()
        ShareModule.onLogout()
        JoinUsModule.onLogout()
        WalletModule.onLogout()
        SettingModule.onLogout()
        ActivityModule.onLogout()
        PlaymateModule.onLogout()
        GiftModule.onLogout()
        AccountModule.onLogout()
        ProfileModule.onLogout()
        IMModule.onLogout()
    }
}