mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
When replying from notification, do not interfere with specialModeEventTimelineItem
This commit is contained in:
committed by
Benoit Marty
parent
7c559363a4
commit
3ddec73ac5
+2
-2
@@ -395,7 +395,7 @@ class MessageComposerPresenterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - reply message`() = runTest {
|
fun `present - reply message`() = runTest {
|
||||||
val replyMessageLambda = lambdaRecorder { _: EventId, _: String, _: String?, _: List<Mention> ->
|
val replyMessageLambda = lambdaRecorder { _: EventId, _: String, _: String?, _: List<Mention>, _: Boolean ->
|
||||||
Result.success(Unit)
|
Result.success(Unit)
|
||||||
}
|
}
|
||||||
val timeline = FakeTimeline().apply {
|
val timeline = FakeTimeline().apply {
|
||||||
@@ -909,7 +909,7 @@ class MessageComposerPresenterTest {
|
|||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Test
|
@Test
|
||||||
fun `present - send messages with intentional mentions`() = runTest {
|
fun `present - send messages with intentional mentions`() = runTest {
|
||||||
val replyMessageLambda = lambdaRecorder { _: EventId, _: String, _: String?, _: List<Mention> ->
|
val replyMessageLambda = lambdaRecorder { _: EventId, _: String, _: String?, _: List<Mention>, _: Boolean ->
|
||||||
Result.success(Unit)
|
Result.success(Unit)
|
||||||
}
|
}
|
||||||
val editMessageLambda = lambdaRecorder { _: EventId?, _: TransactionId?, _: String, _: String?, _: List<Mention> ->
|
val editMessageLambda = lambdaRecorder { _: EventId?, _: TransactionId?, _: String, _: String?, _: List<Mention> ->
|
||||||
|
|||||||
+7
-1
@@ -57,7 +57,13 @@ interface Timeline : AutoCloseable {
|
|||||||
|
|
||||||
suspend fun enterSpecialMode(eventId: EventId?): Result<Unit>
|
suspend fun enterSpecialMode(eventId: EventId?): Result<Unit>
|
||||||
|
|
||||||
suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?, mentions: List<Mention>): Result<Unit>
|
suspend fun replyMessage(
|
||||||
|
eventId: EventId,
|
||||||
|
body: String,
|
||||||
|
htmlBody: String?,
|
||||||
|
mentions: List<Mention>,
|
||||||
|
fromNotification: Boolean = false,
|
||||||
|
): Result<Unit>
|
||||||
|
|
||||||
suspend fun sendImage(
|
suspend fun sendImage(
|
||||||
file: File,
|
file: File,
|
||||||
|
|||||||
+20
-5
@@ -308,13 +308,28 @@ class RustTimeline(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?, mentions: List<Mention>): Result<Unit> = withContext(dispatcher) {
|
override suspend fun replyMessage(
|
||||||
|
eventId: EventId,
|
||||||
|
body: String,
|
||||||
|
htmlBody: String?,
|
||||||
|
mentions: List<Mention>,
|
||||||
|
fromNotification: Boolean,
|
||||||
|
): Result<Unit> = withContext(dispatcher) {
|
||||||
runCatching {
|
runCatching {
|
||||||
val inReplyTo = specialModeEventTimelineItem ?: inner.getEventTimelineItemByEventId(eventId.value)
|
val msg = messageEventContentFromParts(body, htmlBody).withMentions(mentions.map())
|
||||||
inReplyTo.use { eventTimelineItem ->
|
if (fromNotification) {
|
||||||
inner.sendReply(messageEventContentFromParts(body, htmlBody).withMentions(mentions.map()), eventTimelineItem)
|
// When replying from a notification, do not interfere with `specialModeEventTimelineItem`
|
||||||
|
val inReplyTo = inner.getEventTimelineItemByEventId(eventId.value)
|
||||||
|
inReplyTo.use { eventTimelineItem ->
|
||||||
|
inner.sendReply(msg, eventTimelineItem)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val inReplyTo = specialModeEventTimelineItem ?: inner.getEventTimelineItemByEventId(eventId.value)
|
||||||
|
inReplyTo.use { eventTimelineItem ->
|
||||||
|
inner.sendReply(msg, eventTimelineItem)
|
||||||
|
}
|
||||||
|
specialModeEventTimelineItem = null
|
||||||
}
|
}
|
||||||
specialModeEventTimelineItem = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -104,7 +104,8 @@ class FakeTimeline(
|
|||||||
body: String,
|
body: String,
|
||||||
htmlBody: String?,
|
htmlBody: String?,
|
||||||
mentions: List<Mention>,
|
mentions: List<Mention>,
|
||||||
) -> Result<Unit> = { _, _, _, _ ->
|
fromNotification: Boolean,
|
||||||
|
) -> Result<Unit> = { _, _, _, _, _ ->
|
||||||
Result.success(Unit)
|
Result.success(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +114,13 @@ class FakeTimeline(
|
|||||||
body: String,
|
body: String,
|
||||||
htmlBody: String?,
|
htmlBody: String?,
|
||||||
mentions: List<Mention>,
|
mentions: List<Mention>,
|
||||||
|
fromNotification: Boolean,
|
||||||
): Result<Unit> = replyMessageLambda(
|
): Result<Unit> = replyMessageLambda(
|
||||||
eventId,
|
eventId,
|
||||||
body,
|
body,
|
||||||
htmlBody,
|
htmlBody,
|
||||||
mentions
|
mentions,
|
||||||
|
fromNotification,
|
||||||
)
|
)
|
||||||
|
|
||||||
var sendImageLambda: (
|
var sendImageLambda: (
|
||||||
|
|||||||
+2
-1
@@ -179,7 +179,8 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||||||
eventId = threadId.asEventId(),
|
eventId = threadId.asEventId(),
|
||||||
body = message,
|
body = message,
|
||||||
htmlBody = null,
|
htmlBody = null,
|
||||||
mentions = emptyList()
|
mentions = emptyList(),
|
||||||
|
fromNotification = true,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
room.liveTimeline.sendMessage(
|
room.liveTimeline.sendMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user