fix(channels): reflect shared deep-queue state in the full-history chip

deep_requested is per-subscription, but deep backfill is channel-wide and shared:
once any subscriber requests full history, the whole back-catalog arrives for
everyone. The chip only looked at the current user's flag, so a second subscriber
saw a misleading 'get full history' on a channel already queued by someone else.
Add a channel-level deep_in_queue to /api/channels and show an informational
'full history queued' badge (vs the owner's cancelable button) in that case.
This commit is contained in:
npeter83 2026-06-12 02:29:10 +02:00
parent 74db6a8f47
commit be3253415f
3 changed files with 39 additions and 14 deletions

View file

@ -36,6 +36,22 @@ def list_channels(
).all():
stored[cid] = count
# Channels already in the *global* deep-backfill queue — i.e. at least one user (any
# user) has requested full history and it isn't done yet. Their whole back-catalogue is
# coming for everyone (video data is shared), so the UI shouldn't offer "get full
# history" to a user who simply hasn't personally opted in.
deep_queued: set[str] = set()
if channel_ids:
for (cid,) in db.execute(
select(Subscription.channel_id)
.where(
Subscription.channel_id.in_(channel_ids),
Subscription.deep_requested.is_(True),
)
.distinct()
).all():
deep_queued.add(cid)
# The user's personal tag links, grouped by channel.
tags_by_channel: dict[str, list[int]] = {}
for cid, tag_id in db.execute(
@ -57,6 +73,7 @@ def list_channels(
"priority": sub.priority,
"hidden": sub.hidden,
"deep_requested": sub.deep_requested,
"deep_in_queue": ch.id in deep_queued and not ch.backfill_done,
"tag_ids": tags_by_channel.get(ch.id, []),
"details_synced": ch.details_synced_at is not None,
"recent_synced": ch.recent_synced_at is not None,