From b440661e0de387b44035b6728567c2da333ef504 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 23 Jul 2024 12:56:53 -0400 Subject: [PATCH] Adds the highlight to the base URL so that when the user opens the link, it highlights on the page. --- .../vitorpamplona/amethyst/ui/note/types/Highlight.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Highlight.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Highlight.kt index e66f76a1d..0f2872d76 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Highlight.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Highlight.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.note.types +import android.net.Uri import android.util.Log import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.ExperimentalLayoutApi @@ -127,8 +128,9 @@ fun DisplayHighlight( verticalArrangement = Arrangement.Center, ) { DisplayQuoteAuthor( + highlightQuote = highlight, authorHex = authorHex, - url = url, + baseUrl = url, postAddress = postAddress, postVersion = postVersion, accountViewModel = accountViewModel, @@ -139,8 +141,9 @@ fun DisplayHighlight( @Composable private fun DisplayQuoteAuthor( + highlightQuote: String, authorHex: String?, - url: String?, + baseUrl: String?, postAddress: ATag?, postVersion: HexKey?, accountViewModel: AccountViewModel, @@ -196,7 +199,9 @@ private fun DisplayQuoteAuthor( version?.let { DisplayEntryForNote(it, userBase, accountViewModel, nav) } - } else if (url != null) { + } else if (baseUrl != null) { + val url = "$baseUrl${if (baseUrl.contains("#")) "&" else "#"}:~:text=${Uri.encode(highlightQuote)}" + DisplayEntryForAUrl(url, userBase, accountViewModel, nav) } else if (userBase != null) { userBase?.let {