Skip to content

Commit

Permalink
Fix navigating to other instance communities and users (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-log7 authored Jun 5, 2023
1 parent 27471c6 commit ff3c0d0
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,23 @@ class MainActivity : ComponentActivity() {
}
// Only necessary for community deeplinks
composable(
route = "c/{name}",
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "$instance/c/{name}" }
},
route = "{instance}/c/{name}",
deepLinks = listOf(
navDeepLink { uriPattern = "{instance}/c/{name}" },
),
arguments = listOf(
navArgument("name") {
type = NavType.StringType
},
navArgument("instance") {
type = NavType.StringType
},
),
) {
LaunchedEffect(Unit) {
val name = it.arguments?.getString("name")!!
val idOrName = Either.Right(name)
val instance = it.arguments?.getString("instance")!!
val idOrName = Either.Right("$name@$instance")

communityViewModel.fetchCommunity(
idOrName = idOrName,
Expand Down Expand Up @@ -258,19 +262,23 @@ class MainActivity : ComponentActivity() {
}
// Necessary for deep links
composable(
route = "u/{name}",
deepLinks = DEFAULT_LEMMY_INSTANCES.map { instance ->
navDeepLink { uriPattern = "$instance/u/{name}" }
},
route = "{instance}/u/{name}",
deepLinks = listOf(
navDeepLink { uriPattern = "{instance}/u/{name}" },
),
arguments = listOf(
navArgument("name") {
type = NavType.StringType
},
navArgument("instance") {
type = NavType.StringType
},
),
) {
LaunchedEffect(Unit) {
val name = it.arguments?.getString("name")!!
val idOrName = Either.Right(name)
val instance = it.arguments?.getString("instance")!!
val idOrName = Either.Right("$name@$instance")

personProfileViewModel.fetchPersonDetails(
idOrName = idOrName,
Expand Down

0 comments on commit ff3c0d0

Please sign in to comment.