NSCv3: update connection status faster

This commit is contained in:
Milos Kozak 2023-01-21 10:34:55 +01:00
parent f877bb5fb9
commit 0569d2ba0a

View file

@ -16,7 +16,6 @@ import com.google.gson.GsonBuilder
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.validators.ValidatingEditTextPreference
import info.nightscout.database.ValueWrapper import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.interfaces.TraceableDBEntry import info.nightscout.database.entities.interfaces.TraceableDBEntry
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
@ -170,6 +169,7 @@ class NSClientV3Plugin @Inject constructor(
.subscribe({ ev -> .subscribe({ ev ->
nsClientReceiverDelegate.onStatusEvent(ev) nsClientReceiverDelegate.onStatusEvent(ev)
setClient() setClient()
rxBus.send(EventNSClientUpdateGUI())
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventPreferenceChange::class.java) .toObservable(EventPreferenceChange::class.java)
@ -193,7 +193,10 @@ class NSClientV3Plugin @Inject constructor(
disposable += rxBus disposable += rxBus
.toObservable(EventChargingState::class.java) .toObservable(EventChargingState::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ ev -> nsClientReceiverDelegate.onStatusEvent(ev) }, fabricPrivacy::logException) .subscribe({ ev ->
nsClientReceiverDelegate.onStatusEvent(ev)
rxBus.send(EventNSClientUpdateGUI())
}, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventNSClientResend::class.java) .toObservable(EventNSClientResend::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
@ -214,8 +217,9 @@ class NSClientV3Plugin @Inject constructor(
if (it is ValueWrapper.Existing) { if (it is ValueWrapper.Existing) {
if (it.value.timestamp < dateUtil.now() - T.mins(5).plus(T.secs(20)).msecs()) if (it.value.timestamp < dateUtil.now() - T.mins(5).plus(T.secs(20)).msecs())
executeLoop("MAIN_LOOP", forceNew = false) executeLoop("MAIN_LOOP", forceNew = false)
else else {
rxBus.send(EventNSClientNewLog("RECENT", "No need to load")) if (isAllowed) rxBus.send(EventNSClientNewLog("RECENT", "No need to load"))
}
} else executeLoop("MAIN_LOOP", forceNew = false) } else executeLoop("MAIN_LOOP", forceNew = false)
} }
} }