Browse Source

knock : adjust api while sdk is not ready.

pull/3725/head
ganfra 1 week ago
parent
commit
89ac2a6831
  1. 11
      features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt
  2. 20
      features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt
  3. 3
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomFactory.kt

11
features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt

@ -167,9 +167,14 @@ class JoinRoomPresenter @AssistedInject constructor( @@ -167,9 +167,14 @@ class JoinRoomPresenter @AssistedInject constructor(
if (requiresConfirmation) {
cancelKnockAction.value = AsyncAction.ConfirmingNoParams
} else {
matrixClient.getPendingRoom(roomId)?.use { room ->
cancelKnockAction.runUpdatingState {
room.leave()
val room = matrixClient.getRoom(roomId)
if (room == null) {
cancelKnockAction.value = AsyncAction.Failure(RuntimeException())
} else {
room.use {
cancelKnockAction.runUpdatingState {
room.leave()
}
}
}
}

20
features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
package io.element.android.features.joinroom.impl
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
@ -43,7 +42,6 @@ import androidx.compose.ui.text.style.TextOverflow @@ -43,7 +42,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.atomic.atoms.PlaceholderAtom
import io.element.android.libraries.designsystem.atomic.atoms.RoomPreviewDescriptionAtom
import io.element.android.libraries.designsystem.atomic.atoms.RoomPreviewSubtitleAtom
@ -55,6 +53,7 @@ import io.element.android.libraries.designsystem.atomic.molecules.RoomPreviewMem @@ -55,6 +53,7 @@ import io.element.android.libraries.designsystem.atomic.molecules.RoomPreviewMem
import io.element.android.libraries.designsystem.atomic.organisms.RoomPreviewOrganism
import io.element.android.libraries.designsystem.atomic.pages.HeaderFooterPage
import io.element.android.libraries.designsystem.background.LightGradientBackground
import io.element.android.libraries.designsystem.components.BigIcon
import io.element.android.libraries.designsystem.components.async.AsyncActionView
import io.element.android.libraries.designsystem.components.avatar.Avatar
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
@ -142,6 +141,9 @@ fun JoinRoomView( @@ -142,6 +141,9 @@ fun JoinRoomView(
async = state.cancelKnockAction,
onSuccess = { onCancelKnockSuccess() },
onErrorDismiss = { state.eventSink(JoinRoomEvents.ClearActionStates) },
errorMessage = {
stringResource(CommonStrings.error_unknown)
},
confirmationDialog = {
ConfirmationDialog(
content = stringResource(R.string.screen_join_room_cancel_knock_alert_description),
@ -167,7 +169,9 @@ private fun JoinRoomFooter( @@ -167,7 +169,9 @@ private fun JoinRoomFooter(
onGoBack: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier.fillMaxWidth().padding(top = 8.dp)) {
Box(modifier = modifier
.fillMaxWidth()
.padding(top = 8.dp)) {
if (state.contentState is ContentState.Failure) {
Button(
text = stringResource(CommonStrings.action_retry),
@ -321,17 +325,15 @@ private fun JoinRoomContent( @@ -321,17 +325,15 @@ private fun JoinRoomContent(
fun IsKnockedLoadedContent(modifier: Modifier = Modifier) {
BoxWithConstraints(
modifier = modifier
.fillMaxHeight()
.padding(horizontal = 16.dp),
.fillMaxHeight()
.padding(horizontal = 16.dp),
contentAlignment = Alignment.Center,
) {
IconTitleSubtitleMolecule(
modifier = Modifier.sizeIn(minHeight = maxHeight*0.7f),
iconImageVector = CompoundIcons.CheckCircleSolid(),
modifier = Modifier.sizeIn(minHeight = maxHeight * 0.7f),
iconStyle = BigIcon.Style.SuccessSolid,
title = stringResource(R.string.screen_join_room_knock_sent_title),
subTitle = stringResource(R.string.screen_join_room_knock_sent_description),
iconTint = ElementTheme.colors.iconSuccessPrimary,
iconBackgroundTint = ElementTheme.colors.bgSuccessSubtle,
)
}
}

3
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomFactory.kt

@ -137,7 +137,8 @@ class RustRoomFactory( @@ -137,7 +137,8 @@ class RustRoomFactory(
return@withContext null
}
val innerRoom = try {
roomListItem.roomWithoutTimeline()
// TODO use new method when available, for now it'll fail for knocked rooms
roomListItem.invitedRoom()
} catch (e: RoomListException) {
Timber.e(e, "Failed to get pending room for $roomId")
return@withContext null

Loading…
Cancel
Save