diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2022-05-04 16:39:23 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2022-05-04 16:39:23 +0000 |
commit | fa5d60f99a07911a13c579074affd646973655b6 (patch) | |
tree | 2928f81eb34f41e436e2e7795f1983299ce64b44 /app/src/main/java | |
parent | 6d8ad343c952603a5a4f3af9f41011b644daecfe (diff) | |
parent | 75416b727547b4e52b1ae8fb5d34471d3265c6e2 (diff) |
Merge branch 'fix_241_widget_out_of_date' into 'main'
FIX 241, widget not updated when no leaks
See merge request e/privacy-central/privacycentralapp!50
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt b/app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt index 7efb6b0..6fd9470 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt @@ -29,16 +29,20 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.debounce +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch +import java.time.temporal.ChronoUnit /** * Implementation of App Widget functionality. @@ -88,9 +92,18 @@ class Widget : AppWidgetProvider() { ) }.sample(50) .combine( - trackersStatisticsUseCase.listenUpdates() - .onStart { emit(Unit) } - .debounce(5000) + merge( + trackersStatisticsUseCase.listenUpdates() + .onStart { emit(Unit) } + .debounce(5000), + flow { + while (true) { + emit(Unit) + delay(ChronoUnit.HOURS.duration.toMillis()) + } + } + + ) ) { state, _ -> state.copy( dayStatistics = trackersStatisticsUseCase.getDayTrackersCalls(), |