CrashDetectionEvents -> CrashDetectionEvent
This commit is contained in:
parent
f5c22a7489
commit
54e08f3447
6 changed files with 14 additions and 14 deletions
|
|
@ -15,7 +15,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvent
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionView
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionEvent
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionView
|
||||
|
|
@ -39,7 +39,7 @@ fun RootView(
|
|||
children()
|
||||
|
||||
fun onOpenBugReport() {
|
||||
state.crashDetectionState.eventSink(CrashDetectionEvents.ResetAppHasCrashed)
|
||||
state.crashDetectionState.eventSink(CrashDetectionEvent.ResetAppHasCrashed)
|
||||
state.rageshakeDetectionState.eventSink(RageshakeDetectionEvent.Dismiss)
|
||||
onOpenBugReport.invoke()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
package io.element.android.features.rageshake.api.crash
|
||||
|
||||
sealed interface CrashDetectionEvents {
|
||||
data object ResetAllCrashData : CrashDetectionEvents
|
||||
data object ResetAppHasCrashed : CrashDetectionEvents
|
||||
sealed interface CrashDetectionEvent {
|
||||
data object ResetAllCrashData : CrashDetectionEvent
|
||||
data object ResetAppHasCrashed : CrashDetectionEvent
|
||||
}
|
||||
|
|
@ -11,5 +11,5 @@ package io.element.android.features.rageshake.api.crash
|
|||
data class CrashDetectionState(
|
||||
val appName: String,
|
||||
val crashDetected: Boolean,
|
||||
val eventSink: (CrashDetectionEvents) -> Unit
|
||||
val eventSink: (CrashDetectionEvent) -> Unit
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fun CrashDetectionView(
|
|||
onOpenBugReport: () -> Unit = { },
|
||||
) {
|
||||
fun onPopupDismissed() {
|
||||
state.eventSink(CrashDetectionEvents.ResetAllCrashData)
|
||||
state.eventSink(CrashDetectionEvent.ResetAllCrashData)
|
||||
}
|
||||
|
||||
if (state.crashDetected) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import io.element.android.features.rageshake.api.RageshakeFeatureAvailability
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvent
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionState
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
|
|
@ -48,10 +48,10 @@ class DefaultCrashDetectionPresenter(
|
|||
}
|
||||
}.collectAsState(false)
|
||||
|
||||
fun handleEvent(event: CrashDetectionEvents) {
|
||||
fun handleEvent(event: CrashDetectionEvent) {
|
||||
when (event) {
|
||||
CrashDetectionEvents.ResetAllCrashData -> localCoroutineScope.resetAll()
|
||||
CrashDetectionEvents.ResetAppHasCrashed -> localCoroutineScope.resetAppHasCrashed()
|
||||
CrashDetectionEvent.ResetAllCrashData -> localCoroutineScope.resetAll()
|
||||
CrashDetectionEvent.ResetAppHasCrashed -> localCoroutineScope.resetAppHasCrashed()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import app.cash.molecule.RecompositionMode
|
|||
import app.cash.molecule.moleculeFlow
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvent
|
||||
import io.element.android.features.rageshake.impl.crash.A_CRASH_DATA
|
||||
import io.element.android.features.rageshake.impl.crash.DefaultCrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.impl.crash.FakeCrashDataStore
|
||||
|
|
@ -80,7 +80,7 @@ class CrashDetectionPresenterTest {
|
|||
skipItems(1)
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.crashDetected).isTrue()
|
||||
initialState.eventSink.invoke(CrashDetectionEvents.ResetAppHasCrashed)
|
||||
initialState.eventSink.invoke(CrashDetectionEvent.ResetAppHasCrashed)
|
||||
assertThat(awaitItem().crashDetected).isFalse()
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ class CrashDetectionPresenterTest {
|
|||
skipItems(1)
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.crashDetected).isTrue()
|
||||
initialState.eventSink.invoke(CrashDetectionEvents.ResetAllCrashData)
|
||||
initialState.eventSink.invoke(CrashDetectionEvent.ResetAllCrashData)
|
||||
assertThat(awaitItem().crashDetected).isFalse()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue