Few minor fixes (#1427)

## Description
- Fix always showing the user list on app cold start even with auto sign
in enabled
- Ignore unknown JSON keys when restoring view options or filters from
the database making them more backward compatible for devs switching
branches
- Don't show a view more card on collection detail page rows, it's not
necessary

### Related issues
First bug was introduced by #1367

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-05-21 17:06:46 -04:00 committed by GitHub
parent 223d2d1f71
commit 6f11a3711f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 9 deletions

View file

@ -434,18 +434,18 @@ class MainActivityViewModel
appUpgradeHandler.copySubfont(false) appUpgradeHandler.copySubfont(false)
val prefs = val prefs =
preferences.data.firstOrNull() ?: AppPreferences.getDefaultInstance() preferences.data.firstOrNull() ?: AppPreferences.getDefaultInstance()
val allowAutoSignIn = val profileProtected =
serverRepository.currentUser.value?.let { serverRepository.currentUser.value?.let {
!it.hasPin && !it.requireLogin it.hasPin || it.requireLogin
} == true } == true
if (prefs.signInAutomatically && allowAutoSignIn) { if (prefs.signInAutomatically && !profileProtected) {
val current = val current =
serverRepository.restoreSession( serverRepository.restoreSession(
prefs.currentServerId?.toUUIDOrNull(), prefs.currentServerId?.toUUIDOrNull(),
prefs.currentUserId?.toUUIDOrNull(), prefs.currentUserId?.toUUIDOrNull(),
) )
if (current != null) { if (current != null) {
if (current.user.hasPin) { if (current.user.hasPin || current.user.requireLogin) {
navigationManager.navigateTo(SetupDestination.UserList(current.server)) navigationManager.navigateTo(SetupDestination.UserList(current.server))
} else { } else {
// Restored // Restored

View file

@ -84,6 +84,11 @@ abstract class AppDatabase : RoomDatabase() {
} }
class Converters { class Converters {
private val json =
Json {
ignoreUnknownKeys = true
}
@TypeConverter @TypeConverter
fun convertToString(id: UUID): String = id.toString().replace("-", "") fun convertToString(id: UUID): String = id.toString().replace("-", "")
@ -103,24 +108,24 @@ class Converters {
fun convertSortOrder(sort: String): SortOrder? = SortOrder.fromNameOrNull(sort) fun convertSortOrder(sort: String): SortOrder? = SortOrder.fromNameOrNull(sort)
@TypeConverter @TypeConverter
fun convertGetItemsFilter(filter: GetItemsFilter): String = Json.encodeToString(filter) fun convertGetItemsFilter(filter: GetItemsFilter): String = json.encodeToString(filter)
@TypeConverter @TypeConverter
fun convertGetItemsFilter(filter: String): GetItemsFilter = fun convertGetItemsFilter(filter: String): GetItemsFilter =
try { try {
Json.decodeFromString(filter) json.decodeFromString(filter)
} catch (ex: Exception) { } catch (ex: Exception) {
Timber.e(ex, "Error parsing filter") Timber.e(ex, "Error parsing filter")
GetItemsFilter() GetItemsFilter()
} }
@TypeConverter @TypeConverter
fun convertViewOptions(viewOptions: ViewOptions?): String? = viewOptions?.let { Json.encodeToString(viewOptions) } fun convertViewOptions(viewOptions: ViewOptions?): String? = viewOptions?.let { json.encodeToString(viewOptions) }
@TypeConverter @TypeConverter
fun convertViewOptions(viewOptions: String?): ViewOptions? = fun convertViewOptions(viewOptions: String?): ViewOptions? =
try { try {
viewOptions?.let { Json.decodeFromString(viewOptions) } viewOptions?.let { json.decodeFromString(viewOptions) }
} catch (ex: Exception) { } catch (ex: Exception) {
Timber.e(ex, "Error parsing view options") Timber.e(ex, "Error parsing view options")
null null

View file

@ -84,6 +84,7 @@ fun CollectionRows(
headerComposable = {}, headerComposable = {},
takeFocus = false, takeFocus = false,
showLogo = preferences.appPreferences.interfacePreferences.showLogos, showLogo = preferences.appPreferences.interfacePreferences.showLogos,
showViewMore = false,
modifier = Modifier, modifier = Modifier,
) )
} }

View file

@ -224,6 +224,7 @@ fun HomePage(
showClock = preferences.appPreferences.interfacePreferences.showClock, showClock = preferences.appPreferences.interfacePreferences.showClock,
onUpdateBackdrop = viewModel::updateBackdrop, onUpdateBackdrop = viewModel::updateBackdrop,
showLogo = preferences.appPreferences.interfacePreferences.showLogos, showLogo = preferences.appPreferences.interfacePreferences.showLogos,
showViewMore = true,
onClickViewMore = onClickViewMore, onClickViewMore = onClickViewMore,
modifier = modifier, modifier = modifier,
) )
@ -283,6 +284,7 @@ fun HomePageContent(
showClock: Boolean, showClock: Boolean,
onUpdateBackdrop: (BaseItem) -> Unit, onUpdateBackdrop: (BaseItem) -> Unit,
showLogo: Boolean, showLogo: Boolean,
showViewMore: Boolean,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
loadingState: LoadingState? = null, loadingState: LoadingState? = null,
listState: LazyListState = rememberLazyListState(), listState: LazyListState = rememberLazyListState(),
@ -295,7 +297,6 @@ fun HomePageContent(
modifier = HeaderUtils.modifier, modifier = HeaderUtils.modifier,
) )
}, },
showViewMore: Boolean = true,
onClickViewMore: (RowColumn, HomeRowLoadingState.Success) -> Unit = { _, _ -> }, onClickViewMore: (RowColumn, HomeRowLoadingState.Success) -> Unit = { _, _ -> },
) { ) {
val focusedItem = val focusedItem =