Skip to content

Commit 02ea737

Browse files
authored
feat: correct autorun filter (#434)
1 parent f613bd9 commit 02ea737

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

composeApp/src/commonMain/kotlin/org/ooni/probe/data/repositories/PreferenceRepository.kt

-15
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ class PreferenceRepository(
126126
}
127127
}
128128

129-
fun isDescriptorEnabled(
130-
descriptor: Descriptor,
131-
isAutoRun: Boolean,
132-
): Flow<Boolean> {
133-
val key = getPreferenceKey(
134-
name = descriptor.name,
135-
prefix = (descriptor.source as? Descriptor.Source.Installed)
136-
?.value?.id?.value?.toString(),
137-
autoRun = isAutoRun,
138-
)
139-
return dataStore.data.map {
140-
it[booleanPreferencesKey(key)] == true
141-
}.distinctUntilChanged()
142-
}
143-
144129
fun isNetTestEnabled(
145130
descriptor: Descriptor,
146131
netTest: NetTest,

composeApp/src/commonMain/kotlin/org/ooni/probe/domain/GetAutoRunSpecification.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class GetAutoRunSpecification(
2929
}
3030

3131
private suspend fun List<Descriptor>.filterForAutoRun() =
32-
filter { it.enabled && it.isEnabledForAutoRun() }
32+
filter { it.enabled }
3333
.map { descriptor ->
3434
descriptor.copy(
3535
netTests = descriptor.netTests
@@ -41,14 +41,6 @@ class GetAutoRunSpecification(
4141
// We only want descriptors with any test left
4242
.filter { it.netTests.any() || it.longRunningTests.any() }
4343

44-
private suspend fun Descriptor.isEnabledForAutoRun() =
45-
if (name == "experimental") {
46-
// Only the experimental descriptor has its own auto-run preference
47-
preferenceRepository.isDescriptorEnabled(this, isAutoRun = true).first()
48-
} else {
49-
true
50-
}
51-
5244
private suspend fun Descriptor.isEnabledForAutoRun(netTest: NetTest) =
5345
preferenceRepository.isNetTestEnabled(this, netTest, isAutoRun = true).first()
5446
}

0 commit comments

Comments
 (0)