android: move comments URL hackery to the right location

This commit is contained in:
Harsh Shandilya 2022-03-02 13:40:57 +05:30
parent de28ae2d95
commit c556f26d77
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
2 changed files with 8 additions and 13 deletions

View file

@ -95,7 +95,13 @@ fun rememberPostActions(
}
override fun viewCommentsPage(commentsUrl: String) {
urlLauncher.openUri(commentsUrl)
// Post links from lobste.rs are of the form $baseUrl/s/$postId/$postTitle
// Interestingly, lobste.rs does not actually care for the value of $postTitle, and will
// happily accept both a missing as well as a completely arbitrary $postTitle. We
// leverage this to create a new URL format which looks like
// $baseUrl/s/$postId/$postTitle/r, and does not trigger our deeplinks,
// instead opening in the custom tab as we want it to.
urlLauncher.openUri(commentsUrl.replaceAfterLast('/', "r"))
}
override fun toggleSave(post: SavedPost) {

View file

@ -61,21 +61,10 @@ fun CommentsHeader(
Spacer(Modifier.height(4.dp))
if (postDetails.url.isNotBlank()) {
// Post links from lobste.rs are of the form $baseUrl/s/$postId/$postTitle
// Interestingly, lobste.rs does not actually care for the value of $postTitle, and will
// happily accept both a missing as well as a completely arbitrary $postTitle. We
// leverage this to create a new URL format which looks like
// $baseUrl/s/$postId/$postTitle/r, and does not trigger our deeplinks,
// instead opening in the custom tab as we want it to.
PostLink(
link = postDetails.url,
modifier =
Modifier.clickable {
postActions.viewPost(
postDetails.url,
postDetails.commentsUrl.replaceAfterLast('/', "r")
)
},
Modifier.clickable { postActions.viewPost(postDetails.url, postDetails.commentsUrl) },
)
Spacer(Modifier.height(4.dp))
}