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 * Fixed a crash when clicking an item on the bottom navigation bar
too quickly too quickly
* Removed buggy deeplinks
## [1.44.0] - 2024-03-19 ## [1.44.0] - 2024-03-19

View file

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

View file

@ -48,14 +48,8 @@ fun rememberPostActions(
if (currentRoute != Destinations.Comments.route) navController.navigate(newRoute) if (currentRoute != Destinations.Comments.route) navController.navigate(newRoute)
} }
override fun viewCommentsPage(commentsUrl: String) { override fun viewCommentsPage(post: UIPost) {
// Post links from lobste.rs are of the form $baseUrl/s/$postId/$postTitle urlLauncher.openUri(post.commentsUrl)
// 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: UIPost) { 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.material.icons.automirrored.filled.Reply
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.graphics.vector.rememberVectorPainter
import dev.msfjarvis.claw.common.posts.LobstersCard import dev.msfjarvis.claw.common.posts.LobstersCard
@ -30,7 +29,7 @@ fun LobstersListItem(
SwipeAction( SwipeAction(
icon = rememberVectorPainter(Icons.AutoMirrored.Filled.Reply), icon = rememberVectorPainter(Icons.AutoMirrored.Filled.Reply),
background = MaterialTheme.colorScheme.tertiary, background = MaterialTheme.colorScheme.tertiary,
onSwipe = { postActions.viewCommentsPage(item.commentsUrl) }, onSwipe = { postActions.viewCommentsPage(item) },
) )
SwipeableActionsBox(endActions = listOf(commentsAction)) { SwipeableActionsBox(endActions = listOf(commentsAction)) {
LobstersCard(post = item, postActions = postActions, refresh = refresh, modifier = modifier) 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.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems
import com.deliveryhero.whetstone.compose.injectedViewModel import com.deliveryhero.whetstone.compose.injectedViewModel
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer 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.navigation.Destinations
import dev.msfjarvis.claw.android.ui.rememberPostActions import dev.msfjarvis.claw.android.ui.rememberPostActions
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel 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.CommentsPage
import dev.msfjarvis.claw.common.comments.HTMLConverter import dev.msfjarvis.claw.common.comments.HTMLConverter
import dev.msfjarvis.claw.common.ui.decorations.ClawAppBar import dev.msfjarvis.claw.common.ui.decorations.ClawAppBar
@ -228,7 +226,6 @@ fun LobstersPostsScreen(
enterTransition = { fadeIn(animationSpec = tween(350)) }, enterTransition = { fadeIn(animationSpec = tween(350)) },
exitTransition = { fadeOut(animationSpec = tween(350)) }, exitTransition = { fadeOut(animationSpec = tween(350)) },
) { ) {
val uri = LobstersApi.BASE_URL
composable(route = Destinations.Hottest.route) { composable(route = Destinations.Hottest.route) {
setWebUri("https://lobste.rs/") setWebUri("https://lobste.rs/")
NetworkPosts( NetworkPosts(
@ -252,11 +249,6 @@ fun LobstersPostsScreen(
composable( composable(
route = Destinations.Comments.route, route = Destinations.Comments.route,
arguments = listOf(navArgument("postId") { type = NavType.StringType }), arguments = listOf(navArgument("postId") { type = NavType.StringType }),
deepLinks =
listOf(
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}/.*" },
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}" },
),
) { backStackEntry -> ) { backStackEntry ->
val postId = val postId =
requireNotNull(backStackEntry.arguments?.getString("postId")) { requireNotNull(backStackEntry.arguments?.getString("postId")) {
@ -274,7 +266,6 @@ fun LobstersPostsScreen(
composable( composable(
route = Destinations.User.route, route = Destinations.User.route,
arguments = listOf(navArgument("username") { type = NavType.StringType }), arguments = listOf(navArgument("username") { type = NavType.StringType }),
deepLinks = listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.PLACEHOLDER}" }),
) { backStackEntry -> ) { backStackEntry ->
val username = val username =
requireNotNull(backStackEntry.arguments?.getString("username")) { requireNotNull(backStackEntry.arguments?.getString("username")) {

View file

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

View file

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