fix(queue): route scaffold masthead PLAY through queue; cache QueueItems snapshot
This commit is contained in:
@@ -85,13 +85,15 @@ public partial class AudioPlayerBar : ComponentBase, IAsyncDisposable
|
||||
// Gated on Fixed + non-empty so single-track embeds keep their compact, panel-free bar (UC6).
|
||||
private bool ShowFixedPanel => Fixed && HasQueue;
|
||||
|
||||
// Snapshot the live queue into a NEW list every render. QueueService.Items returns the service's
|
||||
// backing list by reference, so passing it straight through means Blazor parameter diffing sees an
|
||||
// unchanged reference after an in-place Clear/remove/reorder and the child (QueueList /
|
||||
// MudDropContainer) keeps its stale snapshot until reopened (bug #4). Materializing a fresh list per
|
||||
// access forces the parameter to change identity on every mutation, so the panel re-flows immediately.
|
||||
// Cached snapshot of the queue list (bug #4 fix). QueueService.Items returns the service's
|
||||
// backing list by reference, so passing it straight through means Blazor parameter diffing sees
|
||||
// an unchanged reference after an in-place Clear/remove/reorder and the child (QueueList /
|
||||
// MudDropContainer) keeps its stale snapshot until reopened. We snapshot on first access and
|
||||
// rebuild in OnQueueChanged, so every real mutation hands the child a NEW reference while
|
||||
// progress-tick re-renders (the frequent path) reuse the cached one without allocating.
|
||||
private IReadOnlyList<TrackDto>? _queueItemsCache;
|
||||
private IReadOnlyList<TrackDto> QueueItems =>
|
||||
QueueService is null ? [] : QueueService.Items.ToList();
|
||||
_queueItemsCache ??= QueueService is null ? [] : QueueService.Items.ToList();
|
||||
private int QueueCurrentIndex => QueueService?.CurrentIndex ?? -1;
|
||||
|
||||
// Fixed-mode panel collapse state (OQ1 Option A). Default expanded so a release embed shows the
|
||||
@@ -147,6 +149,11 @@ public partial class AudioPlayerBar : ComponentBase, IAsyncDisposable
|
||||
|
||||
private void OnQueueChanged()
|
||||
{
|
||||
// Invalidate the snapshot so QueueItems rebuilds a fresh list on the next render.
|
||||
// This gives Blazor a new reference on every real mutation (bug #4 reactivity preserved)
|
||||
// while progress-tick re-renders that don't go through here keep the cached reference.
|
||||
_queueItemsCache = null;
|
||||
|
||||
// If a removal emptied the queue while the overlay was open, the button disappears (AC1) — close
|
||||
// the overlay so it cannot strand open over an empty queue. The button gate hides the overlay
|
||||
// mount too, so this keeps state and view consistent.
|
||||
|
||||
Reference in New Issue
Block a user