Skip to content

Commit

Permalink
[Feat] DetailViewModel에 share기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hyejin12-ju committed Sep 30, 2024
1 parent 11c1b78 commit 5da6d6d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<DetailUiState, DetailSideEffect, DetailIntent>(savedStateHandle) {

init {
Expand Down Expand Up @@ -64,6 +66,7 @@ class DetailViewModel @Inject constructor(
}

is DetailIntent.ClickBottomButton.Share -> {
incrementShareCount()
postSideEffect(DetailSideEffect.ShareLink(intent.memeId))
}

Expand Down Expand Up @@ -168,6 +171,10 @@ class DetailViewModel @Inject constructor(
}
}

private suspend fun incrementShareCount() {
shareMemeUseCase(currentState.memeId)
}

companion object {
const val TAG = "DetailViewModel"
}
Expand Down

0 comments on commit 5da6d6d

Please sign in to comment.