From 0479049476d7a292dbcef2fcf10e7344b9ab6aaf Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Mon, 21 Mar 2022 15:16:57 +0200 Subject: [PATCH] Permalink to a root thread message will navigate user within the thread timeline --- changelog.d/5567.misc | 1 + .../im/vector/app/features/permalink/PermalinkHandler.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelog.d/5567.misc diff --git a/changelog.d/5567.misc b/changelog.d/5567.misc new file mode 100644 index 0000000000..4c0f5e0ffc --- /dev/null +++ b/changelog.d/5567.misc @@ -0,0 +1 @@ +Permalinks to root thread messages will now navigate you within the thread timeline \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt index fa7b5aa7bc..f840e9ea6f 100644 --- a/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt +++ b/vector/src/main/java/im/vector/app/features/permalink/PermalinkHandler.kt @@ -38,6 +38,7 @@ import org.matrix.android.sdk.api.session.permalinks.PermalinkService import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.RoomType +import org.matrix.android.sdk.api.session.room.timeline.isRootThread import javax.inject.Inject class PermalinkHandler @Inject constructor(private val activeSessionHolder: ActiveSessionHolder, @@ -89,7 +90,13 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti val rootThreadEventId = permalinkData.eventId?.let { eventId -> val room = roomId?.let { session?.getRoom(it) } - room?.getTimelineEvent(eventId)?.root?.getRootThreadEventId() + + val rootThreadEventId = room?.getTimelineEvent(eventId)?.root?.getRootThreadEventId() + rootThreadEventId ?: if (room?.getTimelineEvent(eventId)?.isRootThread() == true) { + eventId + } else { + null + } } openRoom( navigationInterceptor,