From 1c1e64a5b9f544e94fddc605cbd9d8e4171ebda3 Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:05:41 -0400 Subject: [PATCH] Fix focus on home page load defaulting to nav drawer (#68) When the home page loaded, it would only try to focus on the "Resume" row even if there were no items in that row (so it doesn't appear). This resulted in the focus defaulting instead to the nav drawer. This PR fixes focus so it always starts with the first item in the first row of the home page. --- .../wholphin/ui/main/HomeViewModel.kt | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt index 080d3771..3db3f630 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomeViewModel.kt @@ -82,17 +82,29 @@ class HomeViewModel val latest = getLatest(userDto, limit, includedIds) val homeRows = - listOf( - HomeRow( - section = HomeSection.RESUME, - items = resume, - ), - HomeRow( - section = HomeSection.NEXT_UP, - items = nextUp, - ), - *latest.toTypedArray(), - ) + buildList { + if (resume.isNotEmpty()) { + add( + HomeRow( + section = HomeSection.RESUME, + items = resume, + ), + ) + } + if (nextUp.isNotEmpty()) { + add( + HomeRow( + section = HomeSection.NEXT_UP, + items = nextUp, + ), + ) + } + latest.forEach { + if (it.items.isNotEmpty()) { + add(it) + } + } + } withContext(Dispatchers.Main) { this@HomeViewModel.homeRows.value = homeRows loadingState.value = LoadingState.Success