Skip to content

Commit c9c2d8d

Browse files
committed
#2053 do not use stateflow so tests are simpler and in case this introduces inconsistent state bugs
1 parent 7cb5d82 commit c9c2d8d

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

base/src/main/java/io/github/sds100/keymapper/base/actions/GetActionErrorUseCase.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@ import io.github.sds100.keymapper.system.permissions.SystemFeatureAdapter
1414
import io.github.sds100.keymapper.system.ringtones.RingtoneAdapter
1515
import javax.inject.Inject
1616
import javax.inject.Singleton
17-
import kotlinx.coroutines.CoroutineScope
1817
import kotlinx.coroutines.flow.Flow
19-
import kotlinx.coroutines.flow.SharingStarted
20-
import kotlinx.coroutines.flow.StateFlow
2118
import kotlinx.coroutines.flow.channelFlow
2219
import kotlinx.coroutines.flow.collectLatest
2320
import kotlinx.coroutines.flow.drop
2421
import kotlinx.coroutines.flow.map
2522
import kotlinx.coroutines.flow.merge
26-
import kotlinx.coroutines.flow.stateIn
2723

2824
@Singleton
2925
class GetActionErrorUseCaseImpl @Inject constructor(
30-
private val coroutineScope: CoroutineScope,
3126
private val packageManagerAdapter: PackageManagerAdapter,
3227
private val inputMethodAdapter: InputMethodAdapter,
3328
private val switchImeInterface: SwitchImeInterface,
@@ -54,13 +49,13 @@ class GetActionErrorUseCaseImpl @Inject constructor(
5449
),
5550
)
5651

57-
override val actionErrorSnapshot: StateFlow<ActionErrorSnapshot> = channelFlow {
52+
override val actionErrorSnapshot: Flow<ActionErrorSnapshot> = channelFlow {
5853
send(createSnapshot())
5954

6055
invalidateActionErrors.collectLatest {
6156
send(createSnapshot())
6257
}
63-
}.stateIn(coroutineScope, SharingStarted.Eagerly, createSnapshot())
58+
}
6459

6560
private fun createSnapshot(): ActionErrorSnapshot {
6661
return LazyActionErrorSnapshot(

base/src/test/java/io/github/sds100/keymapper/base/actions/GetActionErrorUseCaseTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class GetActionErrorUseCaseTest {
6868
mockSystemBridgeConnectionManager = mock()
6969

7070
useCase = GetActionErrorUseCaseImpl(
71-
coroutineScope = testScope,
7271
packageManagerAdapter = mock(),
7372
inputMethodAdapter = fakeInputMethodAdapter,
7473
switchImeInterface = mock(),

0 commit comments

Comments
 (0)