channels: keep the logged-in user's row when it has no videos

The per-user rows are built from the local video listing, so a channel
that never uploaded is invisible to the row build — and an account that
owns only such channels lost its row entirely. tvbot is exactly that
case: the local tvbots channel exists, it has no videos, and while
logged in as tvbot the screen opened on the next user's channels.

The row build now merges the logged-in user's own local channels from
the account-channels listing (already fetched, carries the full card
data) into the locals before grouping; the group sort already puts the
own row first. Verified on the emulator logged in as tvbot: the
"tvbot's Channels" row renders first with the video-less tvbots card.
This commit is contained in:
Jeena 2026-10-19 14:09:27 +00:00
parent e7b15f819e
commit c0a7e94b14

View file

@ -270,7 +270,19 @@ class ChannelsViewModel(private val store: TokenStore) : ViewModel() {
} }
private fun rebuildRowsInner(host: String?) { private fun rebuildRowsInner(host: String?) {
val locals = allChannels.filter { it.host == host } val allLocals = allChannels.filter { it.host == host }
// The video-listing fast path cannot see channels with no videos at all —
// an account owning only such channels used to lose its row entirely
// (tvbot: the local tvbots channel exists, it just never uploaded). Merge
// the logged-in user's own local channels in; the group sort below still
// puts the own row first. The account-channels listing already carries
// the full card shape (avatar/banners/followers), no extra calls.
var locals = allLocals
if (userChannels.isNotEmpty()) {
val missing = userChannels
.filter { it.host == host && allLocals.none { l -> l.name == it.name } }
if (missing.isNotEmpty()) locals = allLocals + missing
}
val ownNames = userChannels.map { c -> c.name }.toSet() val ownNames = userChannels.map { c -> c.name }.toSet()
val byOwner = locals.groupBy { ownerKey(it) } val byOwner = locals.groupBy { ownerKey(it) }
val groups = byOwner.values.map { row -> val groups = byOwner.values.map { row ->