From c556f26d774196ec14e3aae4bf995c412f135468 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 2 Mar 2022 13:40:57 +0530 Subject: [PATCH] android: move comments URL hackery to the right location --- .../kotlin/dev/msfjarvis/claw/android/ui/ext.kt | 8 +++++++- .../msfjarvis/claw/common/comments/CommentEntry.kt | 13 +------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/ext.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/ext.kt index 37fe56e0..17cfb8a5 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/ext.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/ext.kt @@ -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) { diff --git a/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt b/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt index 3eda3ca7..ec3e8f76 100644 --- a/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt +++ b/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt @@ -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)) }