Fix crash

This commit is contained in:
Damontecres 2026-01-30 17:52:41 -05:00
parent 8c33738e31
commit 7345b04061
No known key found for this signature in database
3 changed files with 26 additions and 20 deletions

View file

@ -265,9 +265,7 @@ class MainActivity : AppCompatActivity() {
server = current.server,
startDestination =
requestedDestination
// TODO undo after testing
// ?: Destination.Home(),
?: Destination.HomeSettings,
?: Destination.Home(),
navigationManager = navigationManager,
preferences = preferences,
modifier = Modifier.fillMaxSize(),

View file

@ -199,18 +199,22 @@ class HomeSettingsService
// User local then server/remote otherwise create a default
val settings =
try {
loadFromLocal(userId)
val local = loadFromLocal(userId)
Timber.v("Found local? %s", local != null)
local
} catch (ex: Exception) {
Timber.w(ex, "Error loading local settings")
// TODO show toast?
null
} ?: try {
loadFromServer(userId)
val remote = loadFromServer(userId)
Timber.v("Found remote? %s", remote != null)
remote
} catch (ex: Exception) {
Timber.w(ex, "Error loading remote settings")
null
}
val resolvedSettings = parseFromWebConfig(userId)!!
val resolvedSettings =
if (settings != null) {
Timber.v("Found settings")
// Resolve

View file

@ -47,6 +47,7 @@ import org.jellyfin.sdk.model.serializer.UUIDSerializer
import timber.log.Timber
import java.util.UUID
import javax.inject.Inject
import kotlin.properties.Delegates
@HiltViewModel
class HomeSettingsViewModel
@ -64,6 +65,8 @@ class HomeSettingsViewModel
private val _state = MutableStateFlow(HomePageSettingsState.EMPTY)
val state: StateFlow<HomePageSettingsState> = _state
private var idCounter by Delegates.notNull<Int>()
val discoverEnabled = seerrServerRepository.active
init {
@ -82,6 +85,7 @@ class HomeSettingsViewModel
val currentSettings =
homeSettingsService.currentSettings.first { it != HomePageResolvedSettings.EMPTY }
Timber.v("currentSettings=%s", currentSettings)
idCounter = currentSettings.rows.maxOfOrNull { it.id }?.plus(1) ?: 0
_state.update {
it.copy(
libraries = libraries,
@ -190,7 +194,7 @@ class HomeSettingsViewModel
fun addRow(type: MetaRowType): Job =
viewModelScope.launchIO {
val id = state.value.rows.size
val id = idCounter++
val newRow =
when (type) {
MetaRowType.CONTINUE_WATCHING -> {
@ -239,7 +243,7 @@ class HomeSettingsViewModel
rowType: LibraryRowType,
): Job =
viewModelScope.launchIO {
val id = state.value.rows.size
val id = idCounter++
val newRow =
when (rowType) {
LibraryRowType.RECENTLY_ADDED -> {
@ -288,7 +292,7 @@ class HomeSettingsViewModel
fun addFavoriteRow(type: BaseItemKind): Job =
viewModelScope.launchIO {
Timber.v("Adding favorite row for $type")
val id = state.value.rows.size
val id = idCounter++
val newRow =
HomeRowConfigDisplay(
id = id,