diff --git a/feature/detail/src/main/kotlin/io/github/shinhyo/brba/feature/detail/DetailViewModel.kt b/feature/detail/src/main/kotlin/io/github/shinhyo/brba/feature/detail/DetailViewModel.kt index 1783430..95477d7 100644 --- a/feature/detail/src/main/kotlin/io/github/shinhyo/brba/feature/detail/DetailViewModel.kt +++ b/feature/detail/src/main/kotlin/io/github/shinhyo/brba/feature/detail/DetailViewModel.kt @@ -18,6 +18,7 @@ package io.github.shinhyo.brba.feature.detail import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import androidx.navigation.toRoute import dagger.hilt.android.lifecycle.HiltViewModel import io.github.shinhyo.brba.core.common.result.Result import io.github.shinhyo.brba.core.common.result.asResult @@ -47,12 +48,7 @@ class DetailViewModel @Inject constructor( private val updateFavoriteUseCase: UpdateFavoriteUseCase, ) : ViewModel() { - private val args: Detail by lazy { - Detail( - id = checkNotNull(savedStateHandle.get("id")), - image = checkNotNull(savedStateHandle.get("image")), - ) - } + private val args = savedStateHandle.toRoute() private val _imageState = MutableStateFlow(args.id to args.image) val imageState = _imageState.asStateFlow()