feat(release): front int PK with app-minted GUID EntryKey on the public addressing surface (P11 W5, 11.H)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
<PageTitle>DeepDrft Cuts</PageTitle>
|
||||
|
||||
@* The shared release-card grid; each card routes to /cuts/{id} via the one ReleaseRoutes table.
|
||||
@* The shared release-card grid; each card routes to /cuts/{entryKey} via the one ReleaseRoutes table.
|
||||
Cuts show a track count where other media show the artist, supplied via SubtitleResolver. *@
|
||||
<ReleaseGallery Releases="@_albums"
|
||||
Loading="@_loading"
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace DeepDrftPublic.Client.Pages;
|
||||
/// Medium-filtered release gallery. Routed at <c>/cuts</c> (Cut releases) and parameterized by
|
||||
/// <see cref="Medium"/> so the same component can back any medium's card grid without a fork.
|
||||
/// Cards open the release's dedicated detail page via <see cref="ReleaseRoutes.DetailHref(ReleaseDto)"/>
|
||||
/// (a Cut routes to <c>/cuts/{id}</c>), the single source for medium→route resolution (Phase 11 §2).
|
||||
/// (a Cut routes to <c>/cuts/{entryKey}</c>), the single source for medium→route resolution (Phase 11 §2).
|
||||
/// </summary>
|
||||
public partial class AlbumsView : ComponentBase, IDisposable
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/cuts/{Id:long}"
|
||||
@page "/cuts/{EntryKey}"
|
||||
@using DeepDrftModels.DTOs
|
||||
@using DeepDrftPublic.Client.Controls
|
||||
@using DeepDrftPublic.Client.Services
|
||||
@@ -79,8 +79,8 @@ else
|
||||
Play
|
||||
</MudButton>
|
||||
|
||||
@* Release-mode share: copies the canonical /cuts/{id} URL, not a single track (§3b). *@
|
||||
<SharePopover ReleaseId="@release.Id" ReleaseMedium="@release.Medium" />
|
||||
@* Release-mode share: copies the canonical /cuts/{entryKey} URL, not a single track (§3b). *@
|
||||
<SharePopover ReleaseEntryKey="@release.EntryKey" ReleaseMedium="@release.Medium" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Components;
|
||||
namespace DeepDrftPublic.Client.Pages;
|
||||
|
||||
/// <summary>
|
||||
/// Load + prerender-bridge logic for the Cut album-detail page (/cuts/{id}). Mirrors
|
||||
/// Load + prerender-bridge logic for the Cut album-detail page (/cuts/{entryKey}). Mirrors
|
||||
/// <see cref="ReleaseDetailBase"/>'s discipline (id-addressed load in OnParametersSetAsync,
|
||||
/// PersistentComponentState bridge guarded on id) but carries the multi-track payload (release +
|
||||
/// ordered track list) the Cut page needs. Kept separate from the single-track base so neither
|
||||
@@ -15,16 +15,16 @@ public abstract class CutDetailBase : ComponentBase, IDisposable
|
||||
{
|
||||
private const string PersistKey = "cut-detail";
|
||||
|
||||
[Parameter] public long Id { get; set; }
|
||||
[Parameter] public string EntryKey { get; set; } = string.Empty;
|
||||
[Inject] public required CutDetailViewModel 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.
|
||||
// /cuts/5 -> /cuts/8) which reuse this component instance and fire OnParametersSet without
|
||||
// The release EntryKey the ViewModel currently holds — tracks param-only navigations (e.g.
|
||||
// /cuts/{a} -> /cuts/{b}) which reuse this component instance and fire OnParametersSet without
|
||||
// re-running OnInitialized. Without it the page would keep the prior album's tracks.
|
||||
private long _loadedId;
|
||||
private string? _loadedKey;
|
||||
private bool _loaded;
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -32,25 +32,25 @@ public abstract class CutDetailBase : ComponentBase, IDisposable
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (_loaded && _loadedId == Id) return;
|
||||
if (_loaded && _loadedKey == EntryKey) return;
|
||||
|
||||
// Capture the id synchronously before any await so a re-entrant call (rapid navigation or a
|
||||
// re-render that changes Id while Load is in flight) sees the correct guard state.
|
||||
_loadedId = Id;
|
||||
// Capture the key synchronously before any await so a re-entrant call (rapid navigation or a
|
||||
// re-render that changes EntryKey while Load is in flight) sees the correct guard state.
|
||||
_loadedKey = EntryKey;
|
||||
_loaded = true;
|
||||
|
||||
// The bridged payload carries the release and its ordered tracks so the interactive pass
|
||||
// renders identically without a second round-trip. Guard on the id: a payload for a different
|
||||
// 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<BridgedCut>(PersistKey, out var restored)
|
||||
&& restored?.Release is not null
|
||||
&& restored.Release.Id == Id)
|
||||
&& restored.Release.EntryKey == EntryKey)
|
||||
{
|
||||
ViewModel.Restore(restored.Release, restored.Tracks);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ViewModel.Load(Id);
|
||||
await ViewModel.Load(EntryKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/mixes/{Id:long}"
|
||||
@page "/mixes/{EntryKey}"
|
||||
@using DeepDrftPublic.Client.Controls
|
||||
@inherits ReleaseDetailBase
|
||||
|
||||
@@ -37,7 +37,7 @@ else
|
||||
@* Full-page waveform sits behind the scaffold content. The scaffold's container is positioned
|
||||
above it via the mix-detail-foreground stacking context. TrackId lets the visualizer couple to
|
||||
playback only when the player is on this mix's track. *@
|
||||
<MixWaveformVisualizer ReleaseId="@release.Id" TrackId="@ViewModel.Track?.Id" />
|
||||
<MixWaveformVisualizer ReleaseEntryKey="@release.EntryKey" TrackId="@ViewModel.Track?.Id" />
|
||||
|
||||
<div class="mix-detail-foreground">
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="mix-detail-container">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/sessions/{Id:long}"
|
||||
@page "/sessions/{EntryKey}"
|
||||
@using DeepDrftModels.DTOs
|
||||
@using DeepDrftPublic.Client.Controls
|
||||
@using DeepDrftPublic.Client.Services
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
@page "/tracks/{Id:long}"
|
||||
@page "/tracks/{EntryKey}"
|
||||
@using DeepDrftPublic.Client.Services
|
||||
@inject IReleaseDataService ReleaseData
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* Addressable deep-link fallback for a bare release id (Phase 11 §2, shape iii). Unlike the player
|
||||
bar / Archive / AlbumsView call sites, an external /tracks/{id} link carries only the id, so this
|
||||
page fetches the release to discover its medium, then forwards through the same ReleaseRoutes
|
||||
resolver — one medium→route table, no second source. replace:true keeps the router out of history
|
||||
so Back skips this hop. Capture Id before the await per the InteractiveAuto route-param convention. *@
|
||||
@* Addressable deep-link fallback for a bare release EntryKey (Phase 11 §2, shape iii). Unlike the
|
||||
player bar / Archive / AlbumsView call sites, an external /tracks/{entryKey} link carries only the
|
||||
key, so this page fetches the release to discover its medium, then forwards through the same
|
||||
ReleaseRoutes resolver — one medium→route table, no second source. replace:true keeps the router
|
||||
out of history so Back skips this hop. Capture EntryKey before the await per the InteractiveAuto
|
||||
route-param convention. *@
|
||||
|
||||
@code {
|
||||
[Parameter] public long Id { get; set; }
|
||||
[Parameter] public string EntryKey { get; set; } = string.Empty;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
var id = Id;
|
||||
var result = await ReleaseData.GetById(id);
|
||||
var entryKey = EntryKey;
|
||||
var result = await ReleaseData.GetByEntryKey(entryKey);
|
||||
|
||||
var target = result is { Success: true, Value: { } release }
|
||||
? ReleaseRoutes.DetailHref(release)
|
||||
: "/cuts"; // Unknown id: fall back to the Cuts gallery rather than 404.
|
||||
: "/cuts"; // Unknown key: fall back to the Cuts gallery rather than 404.
|
||||
|
||||
Navigation.NavigateTo(target, forceLoad: false, replace: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user