diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/data/repository/realisations/PsychomatrixCeilDescriptionRepositoryImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/data/repository/realisations/PsychomatrixCeilDescriptionRepositoryImpl.kt index 7a0554e..4c05a19 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/data/repository/realisations/PsychomatrixCeilDescriptionRepositoryImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/data/repository/realisations/PsychomatrixCeilDescriptionRepositoryImpl.kt @@ -2,19 +2,34 @@ package com.github.insanusmokrassar.PsychomatrixBase.data.repository.realisation import com.github.insanusmokrassar.PsychomatrixBase.data.repository.PsychomatrixCeilDescriptionRepository import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CeilDescriptionUseCase +import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription +import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo +import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsDescriptionsRoot +import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.resolveCeilsDescriptionsByLanguage import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe -abstract class PsychomatrixCeilDescriptionRepositoryImpl( - ceilDescriptionUseCase: CeilDescriptionUseCase +const val CEILS_DESCRIPTION_ENGLISH="en_US" + +class PsychomatrixCeilDescriptionRepositoryImpl( + ceilDescriptionUseCase: CeilDescriptionUseCase, + language: String = CEILS_DESCRIPTION_ENGLISH ) : PsychomatrixCeilDescriptionRepository { + + private val ceilsDescriptionsRoot: CeilsDescriptionsRoot = resolveCeilsDescriptionsByLanguage(language) + init { ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe { getCeilDescription(it).also { description -> ceilDescriptionUseCase.descriptionReady( - it, description + it, + description ) } } } + + override fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription { + return ceilsDescriptionsRoot.resolveCeilDescription(psychomatrixCeilInfo) + } } \ No newline at end of file