Skip to content

Commit

Permalink
knock : adjust api while sdk is not ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
ganfra committed Oct 22, 2024
1 parent 512b362 commit 89ac2a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89ac2a6

Please sign in to comment.