Skip to content

Commit

Permalink
Merge pull request #48 from infinum/fix/trigger-init-not-working-prop…
Browse files Browse the repository at this point in the history
…erly-on-first-start

Fix: Trigger active value not correct in some cases
  • Loading branch information
KCeh authored Mar 6, 2024
2 parents 4b5123a + d4741a6 commit 6877def
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
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)
} ?: error("Cannot save null entity")

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

0 comments on commit 6877def

Please sign in to comment.