Skip to content

Commit

Permalink
Feature/43 blank screen on default library is podcast (#44)
Browse files Browse the repository at this point in the history
* fix blank screen when default library is a podcast
  • Loading branch information
GrakovNe authored Nov 10, 2024
1 parent 0301659 commit aad5abd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId = "org.grakovne.lissen"
minSdk = 28
targetSdk = 35
versionCode = 26
versionName = "1.0.25"
versionCode = 27
versionName = "1.0.26"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ fun LoginScreen(
.padding(top = 32.dp)
) {
Button(
onClick = {
viewModel.login()
},
onClick = { viewModel.login() },
modifier = Modifier.weight(1f),
shape = RoundedCornerShape(
topStart = 16.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ class LoginViewModel @Inject constructor(
.fetchLibraries()
.fold(
onSuccess = {
it
val preferredLibrary = it
.find { item -> item.id == account.preferredLibraryId }
?.let { library ->
preferences.savePreferredLibrary(Library(library.id, library.title))
}
?: it.firstOrNull()

preferredLibrary
?.let { library -> preferences.savePreferredLibrary(Library(library.id, library.title)) }
},
onFailure = {
account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ class SettingsViewModel @Inject constructor(
_libraries.value = libraries

val preferredLibrary = preferences.getPreferredLibrary()

_preferredLibrary.value = when (preferredLibrary) {
null -> libraries.firstOrNull()
else ->
libraries
.find { it.id == preferredLibrary.id }
?: libraries.firstOrNull()
else -> libraries.find { it.id == preferredLibrary.id }
}
}

Expand Down

0 comments on commit aad5abd

Please sign in to comment.