Skip to content

Commit 9de2b89

Browse files
authored
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
2 parents 8259336 + 34d05e0 commit 9de2b89

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerPresenter.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ class MessageComposerPresenter @Inject constructor(
167167
)
168168
is MessageComposerEvents.SetMode -> {
169169
messageComposerContext.composerMode = event.composerMode
170-
if (event.composerMode is MessageComposerMode.Reply) {
170+
when (event.composerMode) {
171+
is MessageComposerMode.Reply -> event.composerMode.eventId
172+
is MessageComposerMode.Edit -> event.composerMode.eventId
173+
is MessageComposerMode.Normal -> null
174+
is MessageComposerMode.Quote -> null
175+
}.let { relatedEventId ->
171176
appCoroutineScope.launch {
172-
room.enterReplyMode(event.composerMode.eventId)
177+
room.enterSpecialMode(relatedEventId)
173178
}
174179
}
175180
}

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/TimelineItem.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ sealed interface TimelineItem {
5454
@Immutable
5555
data class Event(
5656
val id: String,
57+
// Note: eventId can be null when the event is a local echo
5758
val eventId: EventId? = null,
5859
val transactionId: TransactionId? = null,
5960
val senderId: UserId,

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
150150
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
151151
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" }
152152
timber = "com.jakewharton.timber:timber:5.0.1"
153-
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.58"
153+
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.59"
154154
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
155155
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
156156
sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ interface MatrixRoom : Closeable {
8989

9090
suspend fun editMessage(originalEventId: EventId?, transactionId: TransactionId?, body: String, htmlBody: String?): Result<Unit>
9191

92-
suspend fun enterReplyMode(eventId: EventId): Result<Unit>
92+
suspend fun enterSpecialMode(eventId: EventId?): Result<Unit>
9393

9494
suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit>
9595

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class RustMatrixRoom(
124124
roomCoroutineScope.cancel()
125125
innerRoom.destroy()
126126
roomListItem.destroy()
127-
inReplyToEventTimelineItem?.destroy()
127+
specialModeEventTimelineItem?.destroy()
128128
}
129129

130130
override val name: String?
@@ -238,7 +238,14 @@ class RustMatrixRoom(
238238
withContext(roomDispatcher) {
239239
if (originalEventId != null) {
240240
runCatching {
241-
innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value)
241+
val editedEvent = specialModeEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(originalEventId.value)
242+
editedEvent.use {
243+
innerRoom.edit(
244+
newContent = messageEventContentFromParts(body, htmlBody),
245+
editItem = it,
246+
)
247+
}
248+
specialModeEventTimelineItem = null
242249
}
243250
} else {
244251
runCatching {
@@ -248,23 +255,23 @@ class RustMatrixRoom(
248255
}
249256
}
250257

251-
private var inReplyToEventTimelineItem: EventTimelineItem? = null
258+
private var specialModeEventTimelineItem: EventTimelineItem? = null
252259

253-
override suspend fun enterReplyMode(eventId: EventId): Result<Unit> = withContext(roomDispatcher) {
260+
override suspend fun enterSpecialMode(eventId: EventId?): Result<Unit> = withContext(roomDispatcher) {
254261
runCatching {
255-
inReplyToEventTimelineItem?.destroy()
256-
inReplyToEventTimelineItem = null
257-
inReplyToEventTimelineItem = innerRoom.getEventTimelineItemByEventId(eventId.value)
262+
specialModeEventTimelineItem?.destroy()
263+
specialModeEventTimelineItem = null
264+
specialModeEventTimelineItem = eventId?.let { innerRoom.getEventTimelineItemByEventId(it.value) }
258265
}
259266
}
260267

261268
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit> = withContext(roomDispatcher) {
262269
runCatching {
263-
val inReplyTo = inReplyToEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(eventId.value)
270+
val inReplyTo = specialModeEventTimelineItem ?: innerRoom.getEventTimelineItemByEventId(eventId.value)
264271
inReplyTo.use { eventTimelineItem ->
265272
innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventTimelineItem)
266273
}
267-
inReplyToEventTimelineItem = null
274+
specialModeEventTimelineItem = null
268275
}
269276
}
270277

libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class FakeMatrixRoom(
208208
var replyMessageParameter: Pair<String, String?>? = null
209209
private set
210210

211-
override suspend fun enterReplyMode(eventId: EventId): Result<Unit> {
211+
override suspend fun enterSpecialMode(eventId: EventId?): Result<Unit> {
212212
return Result.success(Unit)
213213
}
214214

0 commit comments

Comments
 (0)