mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
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:
+4
-2
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user