feat(release): front int PK with app-minted GUID EntryKey on the public addressing surface (P11 W5, 11.H)

This commit is contained in:
daniel-c-harvey
2026-06-16 17:11:55 -04:00
parent fe28573b68
commit f07d29cdcf
37 changed files with 627 additions and 160 deletions
@@ -13,17 +13,17 @@ namespace DeepDrftPublic.Client.Pages;
/// </summary>
public abstract class ReleaseDetailBase : ComponentBase, IDisposable
{
[Parameter] public long Id { get; set; }
[Parameter] public string EntryKey { get; set; } = string.Empty;
[Inject] public required ReleaseDetailViewModel ViewModel { get; set; }
[Inject] public required PersistentComponentState PersistentState { get; set; }
private PersistingComponentStateSubscription _persistingSubscription;
// The release id the ViewModel currently holds. Tracks param-only navigations (e.g.
// /mixes/5 -> /mixes/8) which reuse this component instance and fire OnParametersSet
// The release EntryKey the ViewModel currently holds. Tracks param-only navigations (e.g.
// /mixes/{a} -> /mixes/{b}) which reuse this component instance and fire OnParametersSet
// without re-running OnInitialized — without this, the page would keep the prior
// release's track and Play would stream the wrong audio.
private long _loadedId;
private string? _loadedKey;
private bool _loaded;
// Distinct keys per medium so a Session restore never lands on a Mix page.
@@ -34,31 +34,31 @@ public abstract class ReleaseDetailBase : ComponentBase, IDisposable
protected override async Task OnParametersSetAsync()
{
// Re-run whenever the route id changes. Component instances are reused across
// Re-run whenever the route key changes. Component instances are reused across
// same-template navigations, so the load decision must live here, not in
// OnInitialized (which fires once per instance).
if (_loaded && _loadedId == Id) return;
if (_loaded && _loadedKey == EntryKey) return;
// Capture the id synchronously before any await so that a re-entrant call
// (rapid navigation or a re-render that changes Id while Load is in flight)
// Capture the key synchronously before any await so that a re-entrant call
// (rapid navigation or a re-render that changes EntryKey while Load is in flight)
// sees the correct guard state. Without this, a second OnParametersSetAsync
// for the same Id would bypass the guard above and start a second Load,
// for the same key would bypass the guard above and start a second Load,
// causing two ViewModel.Load calls to race on the single scoped instance.
_loadedId = Id;
_loadedKey = EntryKey;
_loaded = true;
// The bridged payload carries both the release and its resolved track so the interactive
// pass renders identically without a second round-trip. Guard on the id: a payload for a
// pass renders identically without a second round-trip. Guard on the key: a payload for a
// different release must not seed this page (stale-bridge bleed across navigation).
if (PersistentState.TryTakeFromJson<BridgedDetail>(PersistKey, out var restored)
&& restored?.Release is not null
&& restored.Release.Id == Id)
&& restored.Release.EntryKey == EntryKey)
{
ViewModel.Restore(restored.Release, restored.Track);
}
else
{
await ViewModel.Load(Id);
await ViewModel.Load(EntryKey);
}
}