From 0e563332ce06a7b9a750c4c5c8917929b9dc6f9a Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 6 Aug 2026 16:16:13 +0200 Subject: [PATCH] Clean up formatting/detekt --- .../components/async/AsyncActionIndicator.kt | 17 +++++++++++------ .../matrix/api/user/DisplayedStatus.kt | 1 - .../matrix/impl/room/JoinedRustRoom.kt | 2 +- .../android/tests/konsist/KonsistPreviewTest.kt | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionIndicator.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionIndicator.kt index 058225939f..f1a58c243f 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionIndicator.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionIndicator.kt @@ -12,6 +12,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import io.element.android.libraries.architecture.AsyncAction @@ -36,24 +37,24 @@ private val DefaultFailureDuration = 500.milliseconds * never debounced) and auto-dismisses after [failureDuration]. * * @param asyncAction the action whose progress drives the indicator. + * @param loading the composable to display while loading. + * @param failure the composable to display on failure. * @param modifier the modifier to apply to the underlying [AsyncIndicatorHost]. * @param state the [AsyncIndicatorState] backing the host. * @param showDelay how long the loading state must persist before the indicator is shown. * @param minDisplayDuration the minimum duration the loading indicator stays visible once shown. * @param failureDuration how long the failure indicator stays visible before auto-dismissing. - * @param loading the composable to display while loading. - * @param failure the composable to display on failure. */ @Composable fun AsyncActionIndicator( asyncAction: AsyncAction<*>, + loading: @Composable () -> Unit, + failure: @Composable (Throwable) -> Unit, modifier: Modifier = Modifier, state: AsyncIndicatorState = rememberAsyncIndicatorState(), showDelay: Duration = DefaultShowDelay, minDisplayDuration: Duration = DefaultMinDisplayDuration, failureDuration: Duration = DefaultFailureDuration, - loading: @Composable () -> Unit, - failure: @Composable (Throwable) -> Unit, ) { AsyncIndicatorHost(modifier = modifier, state = state) AsyncActionIndicatorEffect( @@ -78,6 +79,9 @@ internal fun AsyncActionIndicatorEffect( failure: @Composable (Throwable) -> Unit, timeSource: TimeSource = TimeSource.Monotonic, ) { + // Referenced inside the restarting LaunchedEffect below, so keep them up to date. + val currentLoading by rememberUpdatedState(loading) + val currentFailure by rememberUpdatedState(failure) // Mark set when the loader actually becomes visible, null while it is hidden. var loaderShownAt by remember { mutableStateOf(null) } LaunchedEffect(asyncAction) { @@ -86,12 +90,13 @@ internal fun AsyncActionIndicatorEffect( // If the operation completes before this delay elapses, the effect is cancelled // and the loader is never shown. delay(showDelay) - state.enqueue(composable = loading) + state.enqueue(composable = currentLoading) loaderShownAt = timeSource.markNow() } is AsyncAction.Failure -> { // Always surface failures immediately, even if the loader was never shown. - state.enqueue(durationMs = failureDuration.inWholeMilliseconds, composable = { failure(asyncAction.error) }) + val error = asyncAction.error + state.enqueue(durationMs = failureDuration.inWholeMilliseconds, composable = { currentFailure(error) }) loaderShownAt = null } is AsyncAction.Success -> { diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/user/DisplayedStatus.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/user/DisplayedStatus.kt index 64cf68cda7..8e4ced7202 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/user/DisplayedStatus.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/user/DisplayedStatus.kt @@ -13,7 +13,6 @@ import kotlinx.parcelize.Parcelize @Immutable sealed interface DisplayedStatus : Parcelable { - /** Useful for adding extension methods. */ companion object diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/JoinedRustRoom.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/JoinedRustRoom.kt index db4cd5f0db..d454d7c775 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/JoinedRustRoom.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/JoinedRustRoom.kt @@ -42,7 +42,6 @@ import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings import io.element.android.libraries.matrix.impl.core.RustSendHandle import io.element.android.libraries.matrix.impl.mapper.map -import io.element.android.libraries.matrix.impl.user.map import io.element.android.libraries.matrix.impl.room.history.map import io.element.android.libraries.matrix.impl.room.join.map import io.element.android.libraries.matrix.impl.room.knock.RustKnockRequest @@ -54,6 +53,7 @@ import io.element.android.libraries.matrix.impl.room.threads.RustThreadsListServ import io.element.android.libraries.matrix.impl.roomdirectory.map import io.element.android.libraries.matrix.impl.timeline.RustTimeline import io.element.android.libraries.matrix.impl.timeline.item.event.TimelineEventContentMapper +import io.element.android.libraries.matrix.impl.user.map import io.element.android.libraries.matrix.impl.util.MessageEventContent import io.element.android.libraries.matrix.impl.util.mxCallbackFlow import io.element.android.libraries.matrix.impl.widget.RustWidgetDriver diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt index e2a387eede..e066a6b7ec 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt @@ -98,6 +98,7 @@ class KonsistPreviewTest { "HomeTopBarSpaceFiltersSelectedPreview", "HomeTopBarSpacesPreview", "HomeTopBarWithIndicatorPreview", + "HomeTopBarWithStatusPreview", "IconsOtherPreview", "MarkdownTextComposerEditPreview", "MatrixBadgeAtomInfoPreview",