mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 19:58:57 +03:00
Remove io.element.thread and add stable m.thread prefix
This commit is contained in:
parent
a53d5bdba2
commit
03f293f216
10 changed files with 17 additions and 20 deletions
|
@ -50,5 +50,5 @@ import com.squareup.moshi.JsonClass
|
|||
data class AggregatedRelations(
|
||||
@Json(name = "m.annotation") val annotations: AggregatedAnnotation? = null,
|
||||
@Json(name = "m.reference") val references: DefaultUnsignedRelationInfo? = null,
|
||||
@Json(name = RelationType.IO_THREAD) val latestThread: LatestThreadUnsignedRelation? = null
|
||||
@Json(name = RelationType.THREAD) val latestThread: LatestThreadUnsignedRelation? = null
|
||||
)
|
||||
|
|
|
@ -392,9 +392,9 @@ fun Event.isReplyRenderedInThread(): Boolean {
|
|||
return isReply() && getRelationContent()?.inReplyTo?.shouldRenderInThread() == true
|
||||
}
|
||||
|
||||
fun Event.isThread(): Boolean = getRelationContentForType(RelationType.IO_THREAD)?.eventId != null
|
||||
fun Event.isThread(): Boolean = getRelationContentForType(RelationType.THREAD)?.eventId != null
|
||||
|
||||
fun Event.getRootThreadEventId(): String? = getRelationContentForType(RelationType.IO_THREAD)?.eventId
|
||||
fun Event.getRootThreadEventId(): String? = getRelationContentForType(RelationType.THREAD)?.eventId
|
||||
|
||||
fun Event.isEdition(): Boolean {
|
||||
return getRelationContentForType(RelationType.REPLACE)?.eventId != null
|
||||
|
|
|
@ -30,7 +30,6 @@ object RelationType {
|
|||
|
||||
/** Lets you define an event which is a thread reply to an existing event.*/
|
||||
const val THREAD = "m.thread"
|
||||
const val IO_THREAD = "io.element.thread"
|
||||
|
||||
/** Lets you define an event which adds a response to an existing event.*/
|
||||
const val RESPONSE = "org.matrix.response"
|
||||
|
|
|
@ -28,7 +28,7 @@ internal object FilterFactory {
|
|||
limit = numberOfEvents,
|
||||
// senders = listOf(userId),
|
||||
// relationSenders = userId?.let { listOf(it) },
|
||||
relationTypes = listOf(RelationType.IO_THREAD)
|
||||
relationTypes = listOf(RelationType.THREAD)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,14 +52,12 @@ data class RoomEventFilter(
|
|||
* A list of relation types which must be exist pointing to the event being filtered.
|
||||
* If this list is absent then no filtering is done on relation types.
|
||||
*/
|
||||
// @Json(name = "related_by_rel_types") val relationTypes: List<String>? = null,
|
||||
@Json(name = "io.element.relation_types") val relationTypes: List<String>? = null, // To be replaced with the above line after the release
|
||||
@Json(name = "related_by_rel_types") val relationTypes: List<String>? = null,
|
||||
/**
|
||||
* A list of senders of relations which must exist pointing to the event being filtered.
|
||||
* If this list is absent then no filtering is done on relation types.
|
||||
*/
|
||||
// @Json(name = "related_by_senders") val relationSenders: List<String>? = null,
|
||||
@Json(name = "io.element.relation_senders") val relationSenders: List<String>? = null, // To be replaced with the above line after the release
|
||||
@Json(name = "related_by_senders") val relationSenders: List<String>? = null,
|
||||
|
||||
/**
|
||||
* A list of room IDs to include. If this list is absent then all rooms are included.
|
||||
|
|
|
@ -239,7 +239,7 @@ internal interface RoomAPI {
|
|||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}")
|
||||
suspend fun getThreadsRelations(@Path("roomId") roomId: String,
|
||||
@Path("eventId") eventId: String,
|
||||
@Path("relationType") relationType: String = RelationType.IO_THREAD,
|
||||
@Path("relationType") relationType: String = RelationType.THREAD,
|
||||
@Query("from") from: String? = null,
|
||||
@Query("to") to: String? = null,
|
||||
@Query("limit") limit: Int? = null
|
||||
|
|
|
@ -353,7 +353,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
url = attachment.queryUri.toString(),
|
||||
relatesTo = rootThreadEventId?.let {
|
||||
RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = it,
|
||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
||||
)
|
||||
|
@ -396,7 +396,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
url = attachment.queryUri.toString(),
|
||||
relatesTo = rootThreadEventId?.let {
|
||||
RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = it,
|
||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
||||
)
|
||||
|
@ -426,7 +426,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
voiceMessageIndicator = if (!isVoiceMessage) null else emptyMap(),
|
||||
relatesTo = rootThreadEventId?.let {
|
||||
RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = it,
|
||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
||||
)
|
||||
|
@ -446,7 +446,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
url = attachment.queryUri.toString(),
|
||||
relatesTo = rootThreadEventId?.let {
|
||||
RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = it,
|
||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
||||
)
|
||||
|
@ -479,7 +479,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
private fun enhanceStickerIfNeeded(type: String, content: Content?): Content? {
|
||||
var newContent: Content? = null
|
||||
if (type == EventType.STICKER) {
|
||||
val isThread = (content.toModel<MessageStickerContent>())?.relatesTo?.type == RelationType.IO_THREAD
|
||||
val isThread = (content.toModel<MessageStickerContent>())?.relatesTo?.type == RelationType.THREAD
|
||||
val rootThreadEventId = (content.toModel<MessageStickerContent>())?.relatesTo?.eventId
|
||||
if (isThread && rootThreadEventId != null) {
|
||||
val newRelationalDefaultContent = (content.toModel<MessageStickerContent>())?.relatesTo?.copy(
|
||||
|
@ -579,7 +579,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null, showAsReply: Boolean): RelationDefaultContent =
|
||||
rootThreadEventId?.let {
|
||||
RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = it,
|
||||
inReplyTo = ReplyToContent(eventId = eventId, renderIn = if (showAsReply) arrayListOf("m.thread") else null))
|
||||
} ?: RelationDefaultContent(null, null, ReplyToContent(eventId = eventId))
|
||||
|
|
|
@ -58,7 +58,7 @@ fun TextContent.toThreadTextContent(
|
|||
format = MessageFormat.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
||||
body = text,
|
||||
relatesTo = RelationDefaultContent(
|
||||
type = RelationType.IO_THREAD,
|
||||
type = RelationType.THREAD,
|
||||
eventId = rootThreadEventId,
|
||||
inReplyTo = ReplyToContent(
|
||||
eventId = latestThreadEventId
|
||||
|
|
|
@ -332,7 +332,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
|||
.findAll()
|
||||
cacheEventRootId.add(rootThreadEventId)
|
||||
return threadList.filter {
|
||||
it.asDomain().getRelationContentForType(RelationType.IO_THREAD)?.inReplyTo?.eventId == currentEventId
|
||||
it.asDomain().getRelationContentForType(RelationType.THREAD)?.inReplyTo?.eventId == currentEventId
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
|||
* @param event
|
||||
*/
|
||||
private fun isThreadEvent(event: Event): Boolean =
|
||||
event.content.toModel<MessageRelationContent>()?.relatesTo?.type == RelationType.IO_THREAD
|
||||
event.content.toModel<MessageRelationContent>()?.relatesTo?.type == RelationType.THREAD
|
||||
|
||||
/**
|
||||
* Returns the root thread eventId or null otherwise
|
||||
|
|
|
@ -506,7 +506,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
|
||||
private fun handleSendSticker(action: RoomDetailAction.SendSticker) {
|
||||
val content = initialState.rootThreadEventId?.let {
|
||||
action.stickerContent.copy(relatesTo = RelationDefaultContent(RelationType.IO_THREAD, it))
|
||||
action.stickerContent.copy(relatesTo = RelationDefaultContent(RelationType.THREAD, it))
|
||||
} ?: action.stickerContent
|
||||
|
||||
room.sendEvent(EventType.STICKER, content.toContent())
|
||||
|
|
Loading…
Add table
Reference in a new issue