Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
HI-JIN2 committed Oct 15, 2024
1 parent 198aba7 commit 93e97ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
package com.eatssu.android.presentation.info

import android.util.Log
import androidx.lifecycle.ViewModel
import com.eatssu.android.data.enums.Restaurant
import com.eatssu.android.domain.model.RestaurantInfo
import com.eatssu.android.data.repository.FirebaseRemoteConfigRepository
import com.eatssu.android.domain.model.RestaurantInfo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
class InfoViewModel @Inject constructor(
private val firebaseRemoteConfigRepository: FirebaseRemoteConfigRepository
firebaseRemoteConfigRepository: FirebaseRemoteConfigRepository
) : ViewModel() {

// StateFlow to hold restaurant info list
private val _infoList = MutableStateFlow<List<RestaurantInfo>>(emptyList())
val infoList: StateFlow<List<RestaurantInfo>> = _infoList.asStateFlow()

// Map to hold restaurant info
private val restaurantInfoMap: MutableMap<Restaurant, RestaurantInfo> = mutableMapOf()

init {
// Load cafeteria info from repository and update the StateFlow
_infoList.value = firebaseRemoteConfigRepository.getCafeteriaInfo()
Log.d("InfoViewModel", _infoList.value.toString())
Timber.d(_infoList.value.toString())
_infoList.value.forEach { restaurantInfo ->
restaurantInfoMap[restaurantInfo.enum] = restaurantInfo
}
}

// Helper function to get restaurant details
fun getRestaurantInfo(restaurant: Restaurant): RestaurantInfo? {
return restaurantInfoMap[restaurant]
}
Expand Down

0 comments on commit 93e97ef

Please sign in to comment.