Fix close error dialog has no effect.

This commit is contained in:
Benoit Marty 2023-03-16 15:39:38 +01:00 committed by Benoit Marty
parent fc2dfacd7e
commit 8302af2dc6
4 changed files with 12 additions and 0 deletions

View file

@ -19,6 +19,8 @@ package io.element.android.features.rageshake.impl.bugreport
sealed interface BugReportEvents {
object SendBugReport : BugReportEvents
object ResetAll : BugReportEvents
object ClearError : BugReportEvents
data class SetDescription(val description: String) : BugReportEvents
data class SetSendLog(val sendLog: Boolean) : BugReportEvents
data class SetSendCrashLog(val sendCrashlog: Boolean) : BugReportEvents

View file

@ -109,6 +109,10 @@ class BugReportPresenter @Inject constructor(
is BugReportEvents.SetSendScreenshot -> updateFormState(formState) {
copy(sendScreenshot = event.sendScreenshot)
}
BugReportEvents.ClearError -> {
sendingProgress.value = 0f
sendingAction.value = Async.Uninitialized
}
}
}

View file

@ -204,6 +204,7 @@ fun BugReportView(
}
is Async.Failure -> ErrorDialog(
content = state.sending.error.toString(),
onDismiss = { state.eventSink(BugReportEvents.ClearError) }
)
else -> Unit
}

View file

@ -222,6 +222,11 @@ class BugReportPresenterTest {
// Failure
assertThat(awaitItem().sendingProgress).isEqualTo(0f)
assertThat((awaitItem().sending as Async.Failure).error.message).isEqualTo(A_FAILURE_REASON)
// Reset failure
initialState.eventSink.invoke(BugReportEvents.ClearError)
val lastItem = awaitItem()
assertThat(lastItem.sendingProgress).isEqualTo(0f)
assertThat(lastItem.sending).isInstanceOf(Async.Uninitialized::class.java)
}
}