From d8b2ff6c8dcc6a3147eae1de269c81c657b4db85 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 27 Apr 2024 16:56:16 +0530 Subject: [PATCH] fix(android): add missing user destination to search screen Fixes COMPOSE-LOBSTERS-3V --- CHANGELOG.md | 5 +++++ .../claw/android/ui/screens/SearchScreen.kt | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f2f80a..70d7349b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Navigating to user profiles now works when invoked from the search + results page + ## [1.46.0] - 2024-04-24 ### Changed diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/SearchScreen.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/SearchScreen.kt index a97657f7..dd1f4603 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/SearchScreen.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/SearchScreen.kt @@ -24,6 +24,7 @@ import dev.msfjarvis.claw.android.viewmodel.ClawViewModel import dev.msfjarvis.claw.common.comments.CommentsPage import dev.msfjarvis.claw.common.comments.HTMLConverter import dev.msfjarvis.claw.common.urllauncher.UrlLauncher +import dev.msfjarvis.claw.common.user.UserProfile @Composable fun SearchScreen( @@ -74,6 +75,25 @@ fun SearchScreen( }, ) } + composable( + route = Destinations.User.route, + arguments = listOf(navArgument("username") { type = NavType.StringType }), + ) { backStackEntry -> + val username = + requireNotNull(backStackEntry.arguments?.getString("username")) { + "Navigating to ${Destinations.User.route} without necessary 'username' argument" + } + setWebUri("https://lobste.rs/u/$username") + UserProfile( + username = username, + getProfile = viewModel::getUserProfile, + openUserProfile = { + navController.navigate( + Destinations.User.route.replace(Destinations.User.PLACEHOLDER, it) + ) + }, + ) + } } } }