package com.example.wabi.view

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.wabi.domain.network.SupabaseServiceImpl
import com.example.wabi.domain.repository.PrefManager
import com.example.wabi.domain.repository.UserData
import dagger.hilt.android.lifecycle.HiltViewModel

import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(private val sup: SupabaseServiceImpl) : ViewModel() {

    fun isSession(): Boolean {
        var result = false
        viewModelScope.launch {
            result = sup.isSession()
        }
        return result
    }

    fun getThemeState() {
        viewModelScope.launch {
            PrefManager.initPrefManager(UserData.context!!)
            val theme = sup.getThemeOutBase()
            PrefManager.userTheme = if (theme > -1) {
                theme
            } else {
                PrefManager.userTheme
            }
        }
    }


}