From 707397cb9d41a331b83d0a8b02c836aa467d0f1f Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Tue, 18 Jan 2022 15:28:44 +0200 Subject: [PATCH] cleanup --- .../room/relation/DefaultRelationService.kt | 2 ++ .../session/room/send/LocalEchoEventFactory.kt | 8 ++++++++ .../session/room/timeline/LoadTimelineStrategy.kt | 1 - .../session/room/timeline/TimelineChunk.kt | 14 +------------- .../sync/handler/room/ThreadsAwarenessHandler.kt | 2 +- .../java/im/vector/app/features/command/Command.kt | 4 ++-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/DefaultRelationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/DefaultRelationService.kt index 47794e424f..b5b9aa5afb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/DefaultRelationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/DefaultRelationService.kt @@ -176,6 +176,7 @@ internal class DefaultRelationService @AssistedInject constructor( formattedText: String?, eventReplied: TimelineEvent?): Cancelable? { val event = if (eventReplied != null) { + // Reply within a thread eventFactory.createReplyTextEvent( roomId = roomId, eventReplied = eventReplied, @@ -187,6 +188,7 @@ internal class DefaultRelationService @AssistedInject constructor( } ?: return null } else { + // Normal thread reply eventFactory.createThreadTextEvent( rootThreadEventId = rootThreadEventId, roomId = roomId, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt index 86da186222..53ea19e761 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt @@ -457,6 +457,14 @@ internal class LocalEchoEventFactory @Inject constructor( /** * Generates the appropriate relatesTo object for a reply event. * It can either be a regular reply or a reply within a thread + * "m.relates_to": { + * "rel_type": "m.thread", + * "event_id": "$thread_root", + * "m.in_reply_to": { + * "event_id": "$event_target", + * "render_in": ["m.thread"] + * } + * } */ private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null): RelationDefaultContent = rootThreadEventId?.let { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt index 1d92d89a3a..efc11a8bde 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt @@ -171,7 +171,6 @@ internal class LoadTimelineStrategy( } suspend fun loadMore(count: Int, direction: Timeline.Direction, fetchOnServerIfNeeded: Boolean = true): LoadMoreResult { - // / if (mode is Mode.Permalink && timelineChunk == null) { val params = GetContextOfEventTask.Params(roomId, mode.originEventId) try { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt index 20942de408..33f8d88d73 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt @@ -289,22 +289,10 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity, val displayIndex = getNextDisplayIndex(direction) ?: return LoadedFromStorage() val baseQuery = timelineEventEntities.where() -// val timelineEvents = if (timelineSettings.rootThreadEventId != null) { -// baseQuery -// .beginGroup() -// .equalTo(TimelineEventEntityFields.ROOT.ROOT_THREAD_EVENT_ID, timelineSettings.rootThreadEventId) -// .or() -// .equalTo(TimelineEventEntityFields.ROOT.EVENT_ID, timelineSettings.rootThreadEventId) -// .endGroup() -// .offsets(direction, count, displayIndex) -// .findAll() -// .orEmpty() -// } else { val timelineEvents = baseQuery .offsets(direction, count, displayIndex) .findAll() .orEmpty() -// } if (timelineEvents.isEmpty()) return LoadedFromStorage() fetchRootThreadEventsIfNeeded(timelineEvents) @@ -331,7 +319,7 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity, } /** - * Returns whether or not the the thread has reached end. It returned false if the current timeline + * Returns whether or not the the thread has reached end. It returns false if the current timeline * is not a thread timeline */ private fun threadReachedEnd(timelineEvents: List): Boolean = diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt index ee606d1fac..d093aab21f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt @@ -171,7 +171,7 @@ internal class ThreadsAwarenessHandler @Inject constructor( /** * If the event is a thread event then transform/enhance it to a visual Reply Event, * If the event is not a thread event, null value will be returned - * If there is an error (ex. the root/origin thread event is not found), null willl be returend + * If there is an error (ex. the root/origin thread event is not found), null will be returned */ private fun transformThreadToReplyIfNeeded(realm: Realm, roomId: String?, event: Event, decryptedResult: JsonDict?): JsonDict? { roomId ?: return null diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index 5725703c7e..57f228e75d 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -45,8 +45,8 @@ enum class Command(val command: String, REMOVE_USER("/remove", arrayOf("/kick"), " [reason]", R.string.command_description_kick_user, false, false), CHANGE_DISPLAY_NAME("/nick", null, "", R.string.command_description_nick, false, false), CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", arrayOf("/roomnick"), "", R.string.command_description_nick_for_room, false, false), - ROOM_AVATAR("/roomavatar", null, "", R.string.command_description_room_avatar, true /* Since user has to know the mxc url */, false), - CHANGE_AVATAR_FOR_ROOM("/myroomavatar", null, "", R.string.command_description_avatar_for_room, true /* Since user has to know the mxc url */, false), + ROOM_AVATAR("/roomavatar", null, "", R.string.command_description_room_avatar, true /* User has to know the mxc url */, false), + CHANGE_AVATAR_FOR_ROOM("/myroomavatar", null, "", R.string.command_description_avatar_for_room, true /* User has to know the mxc url */, false), MARKDOWN("/markdown", null, "", R.string.command_description_markdown, false, false), RAINBOW("/rainbow", null, "", R.string.command_description_rainbow, false, true), RAINBOW_EMOTE("/rainbowme", null, "", R.string.command_description_rainbow_emote, false, true),