Skip to content

Commit

Permalink
Adds the highlight to the base URL so that when the user opens the li…
Browse files Browse the repository at this point in the history
…nk, it highlights on the page.
  • Loading branch information
vitorpamplona committed Jul 23, 2024
1 parent 38ba456 commit b440661
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,8 +128,9 @@ fun DisplayHighlight(
verticalArrangement = Arrangement.Center,
) {
DisplayQuoteAuthor(
highlightQuote = highlight,
authorHex = authorHex,
url = url,
baseUrl = url,
postAddress = postAddress,
postVersion = postVersion,
accountViewModel = accountViewModel,
Expand All @@ -139,8 +141,9 @@ fun DisplayHighlight(

@Composable
private fun DisplayQuoteAuthor(
highlightQuote: String,
authorHex: String?,
url: String?,
baseUrl: String?,
postAddress: ATag?,
postVersion: HexKey?,
accountViewModel: AccountViewModel,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b440661

Please sign in to comment.