fix: crash when navigating to series with slash in name (#1164)

* fix: crash when navigating to series with slash in name

Remove passing the series name through to the Item screen as it is never used. This stops the crash
occurring as titles such as Fate/Stay night would cause an exception.

* chore: update version name and code

* style: fix extra comma ktlint issue
This commit is contained in:
Troy Rijkaard
2024-01-23 18:13:40 +00:00
committed by GitHub
parent 6f7184073b
commit 97bb23fdd3
9 changed files with 16 additions and 19 deletions

View File

@@ -14,8 +14,8 @@ android {
applicationId = "com.chesire.nekome"
minSdk = 21
targetSdk = libs.versions.sdk.get().toInt()
versionCode = 24012009 // Date of build formatted as 'yyMMddHH'
versionName = "2.2.1"
versionCode = 24012317 // Date of build formatted as 'yyMMddHH'
versionName = "2.2.2"
testInstrumentationRunner = "com.chesire.nekome.TestRunner"
resourceConfigurations += listOf("en", "ja")
}

View File

@@ -43,8 +43,8 @@ fun NavGraphBuilder.addSeriesRoutes(navController: NavHostController) {
arguments = Screen.Anime.args
) {
CollectionScreen(
navigateToItem = { seriesId, seriesTitle ->
navController.navigate("${Screen.Item.destination}/$seriesId/$seriesTitle")
navigateToItem = { seriesId ->
navController.navigate("${Screen.Item.destination}/$seriesId")
},
navigateToSearch = {
navController.navigate(Screen.Search.route)
@@ -57,8 +57,8 @@ fun NavGraphBuilder.addSeriesRoutes(navController: NavHostController) {
arguments = Screen.Manga.args
) {
CollectionScreen(
navigateToItem = { seriesId, seriesTitle ->
navController.navigate("${Screen.Item.destination}/$seriesId/$seriesTitle")
navigateToItem = { seriesId ->
navController.navigate("${Screen.Item.destination}/$seriesId")
},
navigateToSearch = {
navController.navigate(Screen.Search.route)

View File

@@ -78,12 +78,11 @@ sealed class Screen {
}
data object Item : Screen() {
override val route = "item/{seriesId}/{seriesTitle}"
override val route = "item/{seriesId}"
const val destination = "item"
override val args = listOf(
navArgument("seriesId") { type = NavType.IntType },
navArgument("seriesTitle") { type = NavType.StringType }
navArgument("seriesId") { type = NavType.IntType }
)
}

View File

@@ -0,0 +1 @@
* Fix crash when navigating to series detail view, if series has a / in the name

View File

@@ -0,0 +1 @@
* Fix crash when navigating to series detail view, if series has a / in the name

View File

@@ -82,14 +82,14 @@ import com.chesire.nekome.resources.StringResource
@Composable
fun CollectionScreen(
viewModel: CollectionViewModel = hiltViewModel(),
navigateToItem: (Int, String) -> Unit,
navigateToItem: (Int) -> Unit,
navigateToSearch: () -> Unit
) {
val state = viewModel.uiState.collectAsState()
state.value.seriesDetails?.let {
LaunchedEffect(it.show) {
navigateToItem(it.seriesId, it.seriesTitle)
navigateToItem(it.seriesId)
viewModel.execute(ViewAction.SeriesNavigationObserved)
}
}

View File

@@ -117,8 +117,7 @@ class CollectionViewModel @Inject constructor(
state = state.copy(
seriesDetails = SeriesDetails(
show = true,
seriesId = series.userId,
seriesTitle = series.title
seriesId = series.userId
)
)
}

View File

@@ -68,8 +68,7 @@ data class SnackbarData(
data class SeriesDetails(
val show: Boolean,
val seriesId: Int,
val seriesTitle: String
val seriesId: Int
)
data class Sort(

View File

@@ -143,8 +143,7 @@ class CollectionViewModelTest {
assertEquals(
SeriesDetails(
show = true,
seriesId = model.userId,
seriesTitle = model.title
seriesId = model.userId
),
viewModel.uiState.value.seriesDetails
)
@@ -158,8 +157,7 @@ class CollectionViewModelTest {
assertEquals(
SeriesDetails(
show = true,
seriesId = model.userId,
seriesTitle = model.title
seriesId = model.userId
),
viewModel.uiState.value.seriesDetails
)