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.
This commit is contained in:
damontecres 2025-10-26 17:05:41 -04:00 committed by GitHub
parent a4dd404847
commit 1c1e64a5b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -82,17 +82,29 @@ class HomeViewModel
val latest = getLatest(userDto, limit, includedIds) val latest = getLatest(userDto, limit, includedIds)
val homeRows = val homeRows =
listOf( buildList {
HomeRow( if (resume.isNotEmpty()) {
section = HomeSection.RESUME, add(
items = resume, HomeRow(
), section = HomeSection.RESUME,
HomeRow( items = resume,
section = HomeSection.NEXT_UP, ),
items = nextUp, )
), }
*latest.toTypedArray(), if (nextUp.isNotEmpty()) {
) add(
HomeRow(
section = HomeSection.NEXT_UP,
items = nextUp,
),
)
}
latest.forEach {
if (it.items.isNotEmpty()) {
add(it)
}
}
}
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
this@HomeViewModel.homeRows.value = homeRows this@HomeViewModel.homeRows.value = homeRows
loadingState.value = LoadingState.Success loadingState.value = LoadingState.Success