summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/widget/Widget.kt19
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(),