Merge pull request #1486 from vector-im/renovate/org.matrix.rustcomponents-sdk-android-0.x

Update dependency org.matrix.rustcomponents:sdk-android to v0.1.59
This commit is contained in:
Benoit Marty
2023-10-04 22:16:14 +02:00
committed by GitHub
6 changed files with 27 additions and 14 deletions

View File

@@ -167,9 +167,14 @@ class MessageComposerPresenter @Inject constructor(
)
is MessageComposerEvents.SetMode -> {
messageComposerContext.composerMode = event.composerMode
if (event.composerMode is MessageComposerMode.Reply) {
when (event.composerMode) {
is MessageComposerMode.Reply -> event.composerMode.eventId
is MessageComposerMode.Edit -> event.composerMode.eventId
is MessageComposerMode.Normal -> null
is MessageComposerMode.Quote -> null
}.let { relatedEventId ->
appCoroutineScope.launch {
room.enterReplyMode(event.composerMode.eventId)
room.enterSpecialMode(relatedEventId)
}
}
}

View File

@@ -54,6 +54,7 @@ sealed interface TimelineItem {
@Immutable
data class Event(
val id: String,
// Note: eventId can be null when the event is a local echo
val eventId: EventId? = null,
val transactionId: TransactionId? = null,
val senderId: UserId,

View File

@@ -150,7 +150,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" }
timber = "com.jakewharton.timber:timber:5.0.1"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.58"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.59"
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }

View File

@@ -89,7 +89,7 @@ interface MatrixRoom : Closeable {
suspend fun editMessage(originalEventId: EventId?, transactionId: TransactionId?, body: String, htmlBody: String?): Result<Unit>
suspend fun enterReplyMode(eventId: EventId): Result<Unit>
suspend fun enterSpecialMode(eventId: EventId?): Result<Unit>
suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit>

View File

@@ -124,7 +124,7 @@ class RustMatrixRoom(
roomCoroutineScope.cancel()
innerRoom.destroy()
roomListItem.destroy()
inReplyToEventTimelineItem?.destroy()
specialModeEventTimelineItem?.destroy()
}
override val name: String?
@@ -238,7 +238,14 @@ class RustMatrixRoom(
withContext(roomDispatcher) {
if (originalEventId != null) {
runCatching {
innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value)
val editedEvent = specialModeEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(originalEventId.value)
editedEvent.use {
innerRoom.edit(
newContent = messageEventContentFromParts(body, htmlBody),
editItem = it,
)
}
specialModeEventTimelineItem = null
}
} else {
runCatching {
@@ -248,23 +255,23 @@ class RustMatrixRoom(
}
}
private var inReplyToEventTimelineItem: EventTimelineItem? = null
private var specialModeEventTimelineItem: EventTimelineItem? = null
override suspend fun enterReplyMode(eventId: EventId): Result<Unit> = withContext(roomDispatcher) {
override suspend fun enterSpecialMode(eventId: EventId?): Result<Unit> = withContext(roomDispatcher) {
runCatching {
inReplyToEventTimelineItem?.destroy()
inReplyToEventTimelineItem = null
inReplyToEventTimelineItem = innerRoom.getEventTimelineItemByEventId(eventId.value)
specialModeEventTimelineItem?.destroy()
specialModeEventTimelineItem = null
specialModeEventTimelineItem = eventId?.let { innerRoom.getEventTimelineItemByEventId(it.value) }
}
}
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit> = withContext(roomDispatcher) {
runCatching {
val inReplyTo = inReplyToEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(eventId.value)
val inReplyTo = specialModeEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(eventId.value)
inReplyTo.use { eventTimelineItem ->
innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventTimelineItem)
}
inReplyToEventTimelineItem = null
specialModeEventTimelineItem = null
}
}

View File

@@ -208,7 +208,7 @@ class FakeMatrixRoom(
var replyMessageParameter: Pair<String, String?>? = null
private set
override suspend fun enterReplyMode(eventId: EventId): Result<Unit> {
override suspend fun enterSpecialMode(eventId: EventId?): Result<Unit> {
return Result.success(Unit)
}