package com.example.dtf.viewmodels

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.dtf.PreferencesManager
import com.example.dtf.models.User
import com.example.dtf.repositories.offline.OfflineUserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class ProfileViewModel @Inject constructor(
    private val userRepository: OfflineUserRepository
) : ViewModel() {
    private val _user = MutableLiveData<User>()
    val user: LiveData<User>
        get() = _user

    fun retrieveUser(sharedPref: PreferencesManager) {
        _user.postValue(User(null, sharedPref.getData("username", "Nickname")))
    }

    fun logout(sharedPref: PreferencesManager) {
        sharedPref.deleteData("token")
        sharedPref.deleteData("username")
        sharedPref.deleteData("isModerator")
    }
}