Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Trigger active value not correct in some cases #48

Merged
merged 9 commits into from
Mar 6, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal abstract class SensorTrigger(
sensorManager = (context.getSystemService(Context.SENSOR_SERVICE) as? SensorManager)
sensorManager?.let {
registerSensor(it)
this.active = true
} ?: run {
this.active = false
}
Expand All @@ -34,7 +33,6 @@ internal abstract class SensorTrigger(
queue?.clear()
unregisterSensor()
sensorManager = null
this.active = false
}

override fun onSensorChanged(event: SensorEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal class TriggersRepository(
override suspend fun save(input: TriggerParameters) =
input.entity?.let {
dao.save(it)
updateCache(it)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is crucial and probably the fix for all the problems. Good work πŸ‘

} ?: error("Cannot save null entity")

override fun load(input: TriggerParameters): Flow<List<TriggerEntity>> =
Expand Down
Loading