diff options
author | jacquarg <guillaume.jacquart@hoodbrains.com> | 2022-04-29 17:47:06 +0200 |
---|---|---|
committer | jacquarg <guillaume.jacquart@hoodbrains.com> | 2022-04-29 18:47:34 +0200 |
commit | 75416b727547b4e52b1ae8fb5d34471d3265c6e2 (patch) | |
tree | b1310e9e27adeb640bbc7ccb06eea512a6d6d955 /app/src/main | |
parent | dc795e57733d391326c4abbffbe317856aca04fc (diff) |
FIX 241, widget not updated when no leaks
Diffstat (limited to 'app/src/main')
-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(), |