Let AsyncAction.Confirming be an interface, with a AsyncAction.ConfirmingNoParams data object.
This will allow inheritance of `AsyncAction.Confirming` with parameter(s).
This commit is contained in:
parent
c46896be09
commit
97fb7bc2fa
46 changed files with 86 additions and 84 deletions
|
|
@ -26,7 +26,9 @@ sealed interface AsyncAction<out T> {
|
|||
/**
|
||||
* Represents an operation that is currently waiting for user confirmation.
|
||||
*/
|
||||
data object Confirming : AsyncAction<Nothing>
|
||||
interface Confirming : AsyncAction<Nothing>
|
||||
|
||||
data object ConfirmingNoParams : Confirming
|
||||
|
||||
/**
|
||||
* Represents an operation that is currently ongoing.
|
||||
|
|
@ -70,7 +72,7 @@ sealed interface AsyncAction<out T> {
|
|||
|
||||
fun isUninitialized(): Boolean = this == Uninitialized
|
||||
|
||||
fun isConfirming(): Boolean = this == Confirming
|
||||
fun isConfirming(): Boolean = this is Confirming
|
||||
|
||||
fun isLoading(): Boolean = this == Loading
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ open class AsyncActionProvider : PreviewParameterProvider<AsyncAction<Unit>> {
|
|||
override val values: Sequence<AsyncAction<Unit>>
|
||||
get() = sequenceOf(
|
||||
AsyncAction.Uninitialized,
|
||||
AsyncAction.Confirming,
|
||||
AsyncAction.ConfirmingNoParams,
|
||||
AsyncAction.Loading,
|
||||
AsyncAction.Failure(Exception("An error occurred")),
|
||||
AsyncAction.Success(Unit),
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ fun <T> AsyncActionView(
|
|||
) {
|
||||
when (async) {
|
||||
AsyncAction.Uninitialized -> Unit
|
||||
AsyncAction.Confirming -> confirmationDialog()
|
||||
is AsyncAction.Confirming -> confirmationDialog()
|
||||
is AsyncAction.Loading -> progressDialog()
|
||||
is AsyncAction.Failure -> {
|
||||
if (onRetry == null) {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ private fun ColumnScope.TroubleshootTestView(
|
|||
private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNotificationsState) {
|
||||
when (state.testSuiteState.mainState) {
|
||||
AsyncAction.Loading,
|
||||
AsyncAction.Confirming,
|
||||
is AsyncAction.Confirming,
|
||||
is AsyncAction.Success,
|
||||
is AsyncAction.Failure -> {
|
||||
TestSuiteView(
|
||||
|
|
@ -150,7 +150,7 @@ private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNoti
|
|||
})
|
||||
RunTestButton(state = state)
|
||||
}
|
||||
AsyncAction.Confirming -> {
|
||||
is AsyncAction.Confirming -> {
|
||||
ListItem(headlineContent = {
|
||||
Text(
|
||||
text = stringResource(id = R.string.troubleshoot_notifications_screen_waiting)
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ fun List<NotificationTroubleshootTestState>.computeMainState(): AsyncAction<Unit
|
|||
isRunning -> AsyncAction.Loading
|
||||
else -> {
|
||||
if (any { it.status is NotificationTroubleshootTestState.Status.WaitingForUser }) {
|
||||
AsyncAction.Confirming
|
||||
AsyncAction.ConfirmingNoParams
|
||||
} else if (any { it.status is NotificationTroubleshootTestState.Status.Failure }) {
|
||||
AsyncAction.Failure(Exception("Some tests failed"))
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue