From 15f0b19ee673609510caf36e9f0bca290da3fe2a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 7 Sep 2018 20:36:55 +0800 Subject: [PATCH] architecture fixes --- .../domain/interactors/ModifyPsychomatrixUseCaseInteractor.kt | 2 +- .../DefaultRealisations/ModifyPsychomatrixPresenterImpl.kt | 4 ++++ .../presentation/presenters/ModifyPsychomatrixPresenter.kt | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/ModifyPsychomatrixUseCaseInteractor.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/ModifyPsychomatrixUseCaseInteractor.kt index 05487d8..f16e7ba 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/ModifyPsychomatrixUseCaseInteractor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/ModifyPsychomatrixUseCaseInteractor.kt @@ -46,7 +46,7 @@ class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase { private fun asMutablePsychomatrix(psychomatrix: Psychomatrix): MutablePsychomatrix { return currentPsychomatrixes.firstOrNull { - it == psychomatrix + it.date == psychomatrix.date } ?: MutablePsychomatrix(psychomatrix).also { currentPsychomatrixes.add(it) } diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/ModifyPsychomatrixPresenterImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/ModifyPsychomatrixPresenterImpl.kt index 1e75a81..703a84e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/ModifyPsychomatrixPresenterImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/ModifyPsychomatrixPresenterImpl.kt @@ -33,6 +33,10 @@ class ModifyPsychomatrixPresenterImpl( return modifyPsychomatrixUseCase.openPsychomatrixChangedSubscription() } + override suspend fun tryToDoOperation(psychomatrix: Psychomatrix, operation: Operation): Deferred { + return modifyPsychomatrixUseCase.makeConvert(psychomatrix, operation) + } + override suspend fun twoGrowFourAvailable(psychomatrix: Psychomatrix): Deferred { return async { (availableConverts[psychomatrix] ?: updateConvertsOfPsychomatrix(psychomatrix)).contains(TwoGrowFour) diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/ModifyPsychomatrixPresenter.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/ModifyPsychomatrixPresenter.kt index 34b37ca..62e359e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/ModifyPsychomatrixPresenter.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/ModifyPsychomatrixPresenter.kt @@ -11,6 +11,8 @@ interface ModifyPsychomatrixPresenter { fun openPsychomatrixChangedSubscription(): ReceiveChannel + suspend fun tryToDoOperation(psychomatrix: Psychomatrix, operation: Operation): Deferred + suspend fun twoGrowFourAvailable(psychomatrix: Psychomatrix): Deferred suspend fun fourGrowTwoAvailable(psychomatrix: Psychomatrix): Deferred