fix notification about psychomatrix changes

This commit is contained in:
InsanusMokrassar 2018-09-07 22:58:38 +08:00
parent 25e24db57c
commit f436cf2e9f

View File

@ -8,6 +8,7 @@ import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.operations.O
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
import kotlinx.coroutines.experimental.channels.BroadcastChannel import kotlinx.coroutines.experimental.channels.BroadcastChannel
import kotlinx.coroutines.experimental.channels.ReceiveChannel import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.launch
class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase { class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase {
private val currentPsychomatrixes: MutableList<MutablePsychomatrix> = ArrayList() private val currentPsychomatrixes: MutableList<MutablePsychomatrix> = ArrayList()
@ -19,11 +20,21 @@ class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase {
} }
override fun makeConvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean { override fun makeConvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
return asMutablePsychomatrix(psychomatrix).applyConvert(operation) return asMutablePsychomatrix(psychomatrix).applyConvert(operation).also {
if (it) {
launch {
psychomatrixChangedBroadcastChannel.send(psychomatrix to (operation to true))
}
}
}
} }
override fun makeInvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean { override fun makeInvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
return asMutablePsychomatrix(psychomatrix).applyInvert(operation) return asMutablePsychomatrix(psychomatrix).applyInvert(operation).also {
launch {
psychomatrixChangedBroadcastChannel.send(psychomatrix to (operation to false))
}
}
} }
override fun getConverts(psychomatrix: Psychomatrix): List<Operation> { override fun getConverts(psychomatrix: Psychomatrix): List<Operation> {