mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-02 20:26:47 +01:00
Edit emote
This commit is contained in:
parent
98306e223b
commit
d0b145d031
@ -69,7 +69,7 @@ interface RelationService {
|
|||||||
* @param newBodyText The edited body
|
* @param newBodyText The edited body
|
||||||
* @param compatibilityBodyText The text that will appear on clients that don't support yet edition
|
* @param compatibilityBodyText The text that will appear on clients that don't support yet edition
|
||||||
*/
|
*/
|
||||||
fun editTextMessage(targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String = "* $newBodyText"): Cancelable
|
fun editTextMessage(targetEventId: String, msgType: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String = "* $newBodyText"): Cancelable
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,9 +116,9 @@ internal class DefaultRelationService @Inject constructor(private val context: C
|
|||||||
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun editTextMessage(targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable {
|
override fun editTextMessage(targetEventId: String, msgType: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable {
|
||||||
val event = eventFactory
|
val event = eventFactory
|
||||||
.createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, MessageType.MSGTYPE_TEXT, compatibilityBodyText)
|
.createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, msgType, compatibilityBodyText)
|
||||||
.also {
|
.also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
body = compatibilityText,
|
body = compatibilityText,
|
||||||
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId),
|
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId),
|
||||||
newContent = createTextContent(newBodyText, newBodyAutoMarkdown)
|
newContent = createTextContent(newBodyText, newBodyAutoMarkdown)
|
||||||
.toMessageTextContent()
|
.toMessageTextContent(msgType)
|
||||||
.toContent()
|
.toContent()
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ data class TextContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun TextContent.toMessageTextContent(): MessageTextContent {
|
fun TextContent.toMessageTextContent(msgType : String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
||||||
return MessageTextContent(
|
return MessageTextContent(
|
||||||
type = MessageType.MSGTYPE_TEXT,
|
type = msgType,
|
||||||
format = MessageType.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
format = MessageType.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
||||||
body = text,
|
body = text,
|
||||||
formattedBody = formattedText
|
formattedBody = formattedText
|
||||||
|
@ -281,7 +281,7 @@ class PushrulesConditionTest {
|
|||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun editTextMessage(targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable {
|
override fun editTextMessage(targetEventId: String, msgType: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
|
|
||||||
if (nonFormattedBody != action.text) {
|
if (nonFormattedBody != action.text) {
|
||||||
room.editTextMessage(state.sendMode.timelineEvent.root.eventId
|
room.editTextMessage(state.sendMode.timelineEvent.root.eventId
|
||||||
?: "", action.text, action.autoMarkdown)
|
?: "", messageContent?.type ?: MessageType.MSGTYPE_TEXT, action.text, action.autoMarkdown)
|
||||||
} else {
|
} else {
|
||||||
Timber.w("Same message content, do not send edition")
|
Timber.w("Same message content, do not send edition")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user