diff --git a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/BuddyViewModel.kt b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/BuddyViewModel.kt index 48fac46..aa2302e 100644 --- a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/BuddyViewModel.kt +++ b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/BuddyViewModel.kt @@ -12,6 +12,7 @@ import com.nocapstone.buddyvet.buddy.domain.usecase.BuddyUseCase import com.nocapstone.common.domain.usecase.DataStoreUseCase import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.first @@ -22,7 +23,6 @@ import okhttp3.RequestBody.Companion.toRequestBody import javax.inject.Inject - @HiltViewModel class BuddyViewModel @Inject constructor( @ApplicationContext private val context: Context, @@ -81,43 +81,15 @@ class BuddyViewModel @Inject constructor( fun getBuddyLists() = _buddyList.value fun readBuddyList() { - Log.d("refresh","refresh") - val buddyDummy = mutableListOf().apply { - add( - BuddyData( - 1, - "D", - "개주", - "W", - "https://mineme-bucket.s3.ap-northeast-2.amazonaws.com/buddyvet/static/dog.png", - "5년 2개월", - false - ) - ) - }.apply { - add( - BuddyData( - 2, - "C", - "도t", - "M", - "https://mineme-bucket.s3.ap-northeast-2.amazonaws.com/buddyvet/static/cat.png", - "5년 1개월", - false - ) - ) - } - _buddyList.value = buddyDummy - - /* - viewModelScope.launch { + viewModelScope.launch(Dispatchers.IO) { try { - val jwt = dataStoreUseCase.bearerJsonWebToken.first()!! - _buddyList.value = buddyUseCase.readBuddyList(jwt) - }catch (e : Exception){ + val token = dataStoreUseCase.bearerJsonWebToken.first() + if (token != null){ + _buddyList.value = buddyUseCase.readBuddyList(token) + } + } catch (e: Exception) { } } - */ } fun createBuddy() { diff --git a/home/src/main/java/com/nocapstone/home/ui/HomeFragment.kt b/home/src/main/java/com/nocapstone/home/ui/HomeFragment.kt index 4ba4ca7..f9f4629 100644 --- a/home/src/main/java/com/nocapstone/home/ui/HomeFragment.kt +++ b/home/src/main/java/com/nocapstone/home/ui/HomeFragment.kt @@ -60,7 +60,6 @@ class HomeFragment : Fragment() { TedImagePicker.with(requireContext()) .errorListener { } .start { uri -> - //todo eyechackViewModel eyeViewModel.setImage(uri) findNavController().navigate(R.id.next) }