Skip to content

Commit 0f37ce2

Browse files
committed
fix: skip refresh for disabled widgets
1 parent e73fbef commit 0f37ce2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/src/main/java/to/bitkit/repositories/WidgetsRepo.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class WidgetsRepo @Inject constructor(
4444
private val widgetsStore: WidgetsStore,
4545
private val settingsStore: SettingsStore,
4646
) {
47-
// TODO Only refresh in loop widgets displayed in the Home
48-
// TODO Perform a refresh when the preview screen is displayed
4947
private val repoScope = CoroutineScope(bgDispatcher + SupervisorJob())
5048

5149
val widgetsDataFlow = widgetsStore.data
@@ -126,7 +124,14 @@ class WidgetsRepo @Inject constructor(
126124
) {
127125
repoScope.launch {
128126
while (true) {
129-
updateWidget(service, updateStore)
127+
val isEnabled = widgetsDataFlow.first().widgets.any {
128+
it.type == service.widgetType
129+
}
130+
131+
if (isEnabled) {
132+
updateWidget(service, updateStore)
133+
}
134+
130135
delay(service.refreshInterval)
131136
}
132137
}

0 commit comments

Comments
 (0)