remove unused function

This commit is contained in:
Andrei Vereha 2021-05-31 21:00:54 +02:00
parent 7dc01cb1f8
commit 9d61c8ee8a

View file

@ -309,18 +309,19 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
private fun observeNoActiveTempBasal(enforeNew: Boolean): Completable { private fun observeNoActiveTempBasal(enforeNew: Boolean): Completable {
return Completable.create { source -> return Completable.defer {
val expectedState = pumpSync.expectedPumpState() val expectedState = pumpSync.expectedPumpState()
when { when {
expectedState.temporaryBasal == null -> expectedState.temporaryBasal == null ->
source.onComplete() Completable.complete()
!enforeNew -> !enforeNew ->
source.onError( Completable.error(
IllegalStateException( IllegalStateException(
"Temporary basal already active and enforeNew is not set." "Temporary basal already active and enforeNew is not set."
) )
) )
else -> // enforceNew == true else -> // enforceNew == true
// TODO: chain with the completable?
executeSimpleProgrammingCommand( executeSimpleProgrammingCommand(
history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL), history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
omnipodManager.stopTempBasal() omnipodManager.stopTempBasal()
@ -374,29 +375,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
.blockingGet() .blockingGet()
} }
private fun observeCancelTempBasal(): Completable {
return Completable.concat(
listOf(
observeActiveTempBasal(),
podStateManager.observeNoActiveCommand().ignoreElements(),
history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL)
.flatMap { podStateManager.createActiveCommand(it) }
.ignoreElement(),
omnipodManager.stopTempBasal().ignoreElements(),
history.updateFromState(podStateManager),
podStateManager.updateActiveCommand()
.map { handleCommandConfirmation(it) }
.ignoreElement()
)
)
}
private fun handleCommandConfirmation(confirmation: CommandConfirmed) { private fun handleCommandConfirmation(confirmation: CommandConfirmed) {
val historyEntry = history.getById(confirmation.historyId) val historyEntry = history.getById(confirmation.historyId)
when (historyEntry.commandType) { when (historyEntry.commandType) {
OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> OmnipodCommandType.CANCEL_TEMPORARY_BASAL ->
// We can't invalidate this command, // We can't invalidate this command,
// and this is why it pumpSync-ed at this point // and this is why it is pumpSync-ed at this point
if (confirmation.success) { if (confirmation.success) {
pumpSync.syncStopTemporaryBasalWithPumpId( pumpSync.syncStopTemporaryBasalWithPumpId(
historyEntry.createdAt, historyEntry.createdAt,