Simplify the management of inReplyToEventTimelineItem
This commit is contained in:
@@ -20,7 +20,6 @@ import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -152,23 +151,12 @@ class MessageComposerPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
appCoroutineScope.launch {
|
||||
room.exitReplyMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun handleEvents(event: MessageComposerEvents) {
|
||||
when (event) {
|
||||
MessageComposerEvents.ToggleFullScreenState -> isFullScreen.value = !isFullScreen.value
|
||||
MessageComposerEvents.CloseSpecialMode -> {
|
||||
richTextEditorState.setHtml("")
|
||||
messageComposerContext.composerMode = MessageComposerMode.Normal("")
|
||||
appCoroutineScope.launch {
|
||||
room.exitReplyMode()
|
||||
}
|
||||
}
|
||||
is MessageComposerEvents.SendMessage -> appCoroutineScope.sendMessage(
|
||||
message = event.message,
|
||||
@@ -177,11 +165,9 @@ class MessageComposerPresenter @Inject constructor(
|
||||
)
|
||||
is MessageComposerEvents.SetMode -> {
|
||||
messageComposerContext.composerMode = event.composerMode
|
||||
appCoroutineScope.launch {
|
||||
if (event.composerMode is MessageComposerMode.Reply) {
|
||||
if (event.composerMode is MessageComposerMode.Reply) {
|
||||
appCoroutineScope.launch {
|
||||
room.enterReplyMode(event.composerMode.eventId)
|
||||
} else {
|
||||
room.exitReplyMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,6 @@ interface MatrixRoom : Closeable {
|
||||
|
||||
suspend fun enterReplyMode(eventId: EventId): Result<Unit>
|
||||
|
||||
suspend fun exitReplyMode(): Result<Unit>
|
||||
|
||||
suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit>
|
||||
|
||||
suspend fun redactEvent(eventId: EventId, reason: String? = null): Result<Unit>
|
||||
|
||||
@@ -139,6 +139,7 @@ class RustMatrixRoom(
|
||||
roomCoroutineScope.cancel()
|
||||
innerRoom.destroy()
|
||||
roomListItem.destroy()
|
||||
inReplyToEventTimelineItem?.destroy()
|
||||
}
|
||||
|
||||
override val name: String?
|
||||
@@ -272,13 +273,6 @@ class RustMatrixRoom(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun exitReplyMode(): Result<Unit> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
inReplyToEventTimelineItem?.destroy()
|
||||
inReplyToEventTimelineItem = null
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
val inReplyTo = inReplyToEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(eventId.value)
|
||||
|
||||
@@ -212,10 +212,6 @@ class FakeMatrixRoom(
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun exitReplyMode(): Result<Unit> {
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit> {
|
||||
replyMessageParameter = body to htmlBody
|
||||
return Result.success(Unit)
|
||||
|
||||
Reference in New Issue
Block a user