Skip to content

Commit

Permalink
#16 Rename isVideoWatchedUseCase to isMovieWatchedUseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
moallemi committed Jul 6, 2024
1 parent 8051985 commit ce10ac0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.filmtime.data.model.GeneralError
import io.filmtime.data.model.Result
import io.filmtime.data.model.TraktHistory

interface IsVideoWatchedUseCase {
interface IsMovieWatchedUseCase {

suspend operator fun invoke(tmdbId: Int): Result<TraktHistory, GeneralError>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.filmtime.domain.trakt.history.impl.AddToHistoryUseCaseImpl
import io.filmtime.domain.trakt.history.impl.IsVideoWatchedUseCaseImpl
import io.filmtime.domain.trakt.history.impl.IsMovieWatchedUseCaseImpl
import io.filmtime.domain.trakt.history.impl.RemoveFromHistoryUseCaseImpl

@InstallIn(SingletonComponent::class)
@Module
internal abstract class TraktHistoryModule {

@Binds
internal abstract fun bindIsVideoWatchedUseCase(impl: IsVideoWatchedUseCaseImpl): IsVideoWatchedUseCase
internal abstract fun bindIsVideoWatchedUseCase(impl: IsMovieWatchedUseCaseImpl): IsMovieWatchedUseCase

@Binds
internal abstract fun bindAddToHistoryUseCase(impl: AddToHistoryUseCaseImpl): AddToHistoryUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import io.filmtime.data.model.Result
import io.filmtime.data.model.TraktHistory
import io.filmtime.data.model.VideoType.Movie
import io.filmtime.data.trakt.TraktHistoryRepository
import io.filmtime.domain.trakt.history.IsVideoWatchedUseCase
import io.filmtime.domain.trakt.history.IsMovieWatchedUseCase
import javax.inject.Inject

internal class IsVideoWatchedUseCaseImpl @Inject constructor(
internal class IsMovieWatchedUseCaseImpl @Inject constructor(
private val traktHistoryRepository: TraktHistoryRepository,
) : IsVideoWatchedUseCase {
) : IsMovieWatchedUseCase {

override suspend fun invoke(tmdbId: Int): Result<TraktHistory, GeneralError> =
traktHistoryRepository.isWatched(tmdbId = tmdbId, type = Movie)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.filmtime.data.model.Result.Failure
import io.filmtime.data.model.Result.Success
import io.filmtime.data.model.VideoType
import io.filmtime.domain.trakt.history.AddToHistoryUseCase
import io.filmtime.domain.trakt.history.IsVideoWatchedUseCase
import io.filmtime.domain.trakt.history.IsMovieWatchedUseCase
import io.filmtime.domain.trakt.history.RemoveFromHistoryUseCase
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand All @@ -17,7 +17,7 @@ import javax.inject.Inject

@HiltViewModel
internal class TraktHistoryViewModel @Inject constructor(
private val isVideoWatchedUseCase: IsVideoWatchedUseCase,
private val isMovieWatchedUseCase: IsMovieWatchedUseCase,
private val addToHistory: AddToHistoryUseCase,
private val removeFromHistory: RemoveFromHistoryUseCase,
) : ViewModel() {
Expand All @@ -28,7 +28,7 @@ internal class TraktHistoryViewModel @Inject constructor(
fun checkIfIsWatched(videoType: VideoType, tmdbId: Int) = viewModelScope.launch {
_state.update { state -> state.copy(isLoading = true) }

when (val result = isVideoWatchedUseCase(tmdbId)) {
when (val result = isMovieWatchedUseCase(tmdbId)) {
is Success -> _state.update { state ->
state.copy(isWatched = result.data.isWatched, isLoading = false, traktId = result.data.traktId)
}
Expand Down

0 comments on commit ce10ac0

Please sign in to comment.