From 5da6d6d6611b61c3167118a4891a6a0c300024f8 Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Tue, 1 Oct 2024 00:22:08 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20DetailViewModel=EC=97=90=20share?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/team/ppac/detail/DetailViewModel.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailViewModel.kt b/feature/detail/src/main/java/team/ppac/detail/DetailViewModel.kt index f23a9215..92495319 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailViewModel.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailViewModel.kt @@ -16,6 +16,7 @@ import team.ppac.domain.usecase.EmitRefreshEventUseCase import team.ppac.domain.usecase.GetMemeUseCase import team.ppac.domain.usecase.ReactMemeUseCase import team.ppac.domain.usecase.SaveMemeUseCase +import team.ppac.domain.usecase.ShareMemeUseCase import team.ppac.errorhandling.FarmemeNetworkException import javax.inject.Inject @@ -27,6 +28,7 @@ class DetailViewModel @Inject constructor( private val deleteSavedMemeUseCase: DeleteSavedMemeUseCase, private val reactMemeUseCase: ReactMemeUseCase, private val emitRefreshEventUseCase: EmitRefreshEventUseCase, + private val shareMemeUseCase: ShareMemeUseCase, ) : BaseViewModel(savedStateHandle) { init { @@ -64,6 +66,7 @@ class DetailViewModel @Inject constructor( } is DetailIntent.ClickBottomButton.Share -> { + incrementShareCount() postSideEffect(DetailSideEffect.ShareLink(intent.memeId)) } @@ -168,6 +171,10 @@ class DetailViewModel @Inject constructor( } } + private suspend fun incrementShareCount() { + shareMemeUseCase(currentState.memeId) + } + companion object { const val TAG = "DetailViewModel" }