From 6f11a3711f2a4b01953f0844e0d2a95869e72d84 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Thu, 21 May 2026 17:06:46 -0400 Subject: [PATCH] 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 --- .../com/github/damontecres/wholphin/MainActivity.kt | 8 ++++---- .../github/damontecres/wholphin/data/AppDatabase.kt | 13 +++++++++---- .../wholphin/ui/detail/collection/CollectionRows.kt | 1 + .../github/damontecres/wholphin/ui/main/HomePage.kt | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt index 61a4ffc1..bd4a129d 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt @@ -434,18 +434,18 @@ class MainActivityViewModel appUpgradeHandler.copySubfont(false) val prefs = preferences.data.firstOrNull() ?: AppPreferences.getDefaultInstance() - val allowAutoSignIn = + val profileProtected = serverRepository.currentUser.value?.let { - !it.hasPin && !it.requireLogin + it.hasPin || it.requireLogin } == true - if (prefs.signInAutomatically && allowAutoSignIn) { + if (prefs.signInAutomatically && !profileProtected) { val current = serverRepository.restoreSession( prefs.currentServerId?.toUUIDOrNull(), prefs.currentUserId?.toUUIDOrNull(), ) if (current != null) { - if (current.user.hasPin) { + if (current.user.hasPin || current.user.requireLogin) { navigationManager.navigateTo(SetupDestination.UserList(current.server)) } else { // Restored diff --git a/app/src/main/java/com/github/damontecres/wholphin/data/AppDatabase.kt b/app/src/main/java/com/github/damontecres/wholphin/data/AppDatabase.kt index 02a56245..cfd8c41e 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/data/AppDatabase.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/data/AppDatabase.kt @@ -84,6 +84,11 @@ abstract class AppDatabase : RoomDatabase() { } class Converters { + private val json = + Json { + ignoreUnknownKeys = true + } + @TypeConverter fun convertToString(id: UUID): String = id.toString().replace("-", "") @@ -103,24 +108,24 @@ class Converters { fun convertSortOrder(sort: String): SortOrder? = SortOrder.fromNameOrNull(sort) @TypeConverter - fun convertGetItemsFilter(filter: GetItemsFilter): String = Json.encodeToString(filter) + fun convertGetItemsFilter(filter: GetItemsFilter): String = json.encodeToString(filter) @TypeConverter fun convertGetItemsFilter(filter: String): GetItemsFilter = try { - Json.decodeFromString(filter) + json.decodeFromString(filter) } catch (ex: Exception) { Timber.e(ex, "Error parsing filter") GetItemsFilter() } @TypeConverter - fun convertViewOptions(viewOptions: ViewOptions?): String? = viewOptions?.let { Json.encodeToString(viewOptions) } + fun convertViewOptions(viewOptions: ViewOptions?): String? = viewOptions?.let { json.encodeToString(viewOptions) } @TypeConverter fun convertViewOptions(viewOptions: String?): ViewOptions? = try { - viewOptions?.let { Json.decodeFromString(viewOptions) } + viewOptions?.let { json.decodeFromString(viewOptions) } } catch (ex: Exception) { Timber.e(ex, "Error parsing view options") null diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionRows.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionRows.kt index b33e751f..f1e85ee2 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionRows.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionRows.kt @@ -84,6 +84,7 @@ fun CollectionRows( headerComposable = {}, takeFocus = false, showLogo = preferences.appPreferences.interfacePreferences.showLogos, + showViewMore = false, modifier = Modifier, ) } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt index 6877937d..816fcc25 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt @@ -224,6 +224,7 @@ fun HomePage( showClock = preferences.appPreferences.interfacePreferences.showClock, onUpdateBackdrop = viewModel::updateBackdrop, showLogo = preferences.appPreferences.interfacePreferences.showLogos, + showViewMore = true, onClickViewMore = onClickViewMore, modifier = modifier, ) @@ -283,6 +284,7 @@ fun HomePageContent( showClock: Boolean, onUpdateBackdrop: (BaseItem) -> Unit, showLogo: Boolean, + showViewMore: Boolean, modifier: Modifier = Modifier, loadingState: LoadingState? = null, listState: LazyListState = rememberLazyListState(), @@ -295,7 +297,6 @@ fun HomePageContent( modifier = HeaderUtils.modifier, ) }, - showViewMore: Boolean = true, onClickViewMore: (RowColumn, HomeRowLoadingState.Success) -> Unit = { _, _ -> }, ) { val focusedItem =