refactor: remove deeplinks

Fixes #484
This commit is contained in:
Harsh Shandilya 2024-04-18 01:01:21 +05:30
parent d19c1e11be
commit 2b9680d3d8
7 changed files with 9 additions and 122 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed a crash when clicking an item on the bottom navigation bar
too quickly
* Removed buggy deeplinks
## [1.44.0] - 2024-03-19

View File

@ -32,108 +32,8 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/......" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../...*" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/......" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../...*" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/......" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/s/....../...*" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="lobste.rs" />
<data android:pathPattern="/u/......*" />
<data android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".SearchActivity"
android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
@ -161,6 +61,7 @@
android:value="androidx.startup"
tools:node="remove" />
</provider>
<receiver
android:name=".glance.WidgetReceiver"
android:exported="true">
@ -171,6 +72,7 @@
android:name="android.appwidget.provider"
android:resource="@xml/saved_posts_widget_info" />
</receiver>
<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data
android:name="io.sentry.dsn"

View File

@ -48,14 +48,8 @@ fun rememberPostActions(
if (currentRoute != Destinations.Comments.route) navController.navigate(newRoute)
}
override fun viewCommentsPage(commentsUrl: String) {
// 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 viewCommentsPage(post: UIPost) {
urlLauncher.openUri(post.commentsUrl)
}
override fun toggleSave(post: UIPost) {

View File

@ -10,7 +10,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Reply
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import dev.msfjarvis.claw.common.posts.LobstersCard
@ -30,7 +29,7 @@ fun LobstersListItem(
SwipeAction(
icon = rememberVectorPainter(Icons.AutoMirrored.Filled.Reply),
background = MaterialTheme.colorScheme.tertiary,
onSwipe = { postActions.viewCommentsPage(item.commentsUrl) },
onSwipe = { postActions.viewCommentsPage(item) },
)
SwipeableActionsBox(endActions = listOf(commentsAction)) {
LobstersCard(post = item, postActions = postActions, refresh = refresh, modifier = modifier)

View File

@ -58,7 +58,6 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.paging.compose.collectAsLazyPagingItems
import com.deliveryhero.whetstone.compose.injectedViewModel
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
@ -75,7 +74,6 @@ import dev.msfjarvis.claw.android.ui.navigation.ClawNavigationType
import dev.msfjarvis.claw.android.ui.navigation.Destinations
import dev.msfjarvis.claw.android.ui.rememberPostActions
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
import dev.msfjarvis.claw.api.LobstersApi
import dev.msfjarvis.claw.common.comments.CommentsPage
import dev.msfjarvis.claw.common.comments.HTMLConverter
import dev.msfjarvis.claw.common.ui.decorations.ClawAppBar
@ -228,7 +226,6 @@ fun LobstersPostsScreen(
enterTransition = { fadeIn(animationSpec = tween(350)) },
exitTransition = { fadeOut(animationSpec = tween(350)) },
) {
val uri = LobstersApi.BASE_URL
composable(route = Destinations.Hottest.route) {
setWebUri("https://lobste.rs/")
NetworkPosts(
@ -252,11 +249,6 @@ fun LobstersPostsScreen(
composable(
route = Destinations.Comments.route,
arguments = listOf(navArgument("postId") { type = NavType.StringType }),
deepLinks =
listOf(
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}/.*" },
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}" },
),
) { backStackEntry ->
val postId =
requireNotNull(backStackEntry.arguments?.getString("postId")) {
@ -274,7 +266,6 @@ fun LobstersPostsScreen(
composable(
route = Destinations.User.route,
arguments = listOf(navArgument("username") { type = NavType.StringType }),
deepLinks = listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.PLACEHOLDER}" }),
) { backStackEntry ->
val username =
requireNotNull(backStackEntry.arguments?.getString("username")) {

View File

@ -260,7 +260,7 @@ private fun LobstersCardPreview() {
override fun viewComments(postId: String) {}
override fun viewCommentsPage(commentsUrl: String) {}
override fun viewCommentsPage(post: UIPost) {}
override fun toggleSave(post: UIPost) {}

View File

@ -16,7 +16,7 @@ interface PostActions {
fun viewComments(postId: String)
fun viewCommentsPage(commentsUrl: String)
fun viewCommentsPage(post: UIPost)
fun toggleSave(post: UIPost)