Merge p16-w3-anonid into dev (Phase 16 Wave 16.3: unique-listener anonId layer)
This commit is contained in:
@@ -12,6 +12,7 @@ public partial class AudioPlayerProvider : ComponentBase, IAsyncDisposable
|
||||
[Inject] public required ILogger<StreamingAudioPlayerService> Logger { get; set; }
|
||||
[Inject] public required BeaconInterop Beacon { get; set; }
|
||||
[Inject] public required IPlayEventSink PlayEventSink { get; set; }
|
||||
[Inject] public required IAnonIdProvider AnonId { get; set; }
|
||||
|
||||
private IStreamingPlayerService? _audioPlayerService;
|
||||
private QueueService? _queueService;
|
||||
@@ -50,6 +51,20 @@ public partial class AudioPlayerProvider : ComponentBase, IAsyncDisposable
|
||||
_queueService.Attach(_audioPlayerService);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warm the anon-id cache once the provider is interactive (Phase 16 wave 16.3). Done here, after the
|
||||
/// first render, because the localStorage read is JS interop — not available during prerender. By the
|
||||
/// time any play session closes and the sink reads <c>AnonId.Current</c>, the cache is populated; a
|
||||
/// play that somehow closes before this completes simply sends no anonId (acceptable over-count). The
|
||||
/// provider is the natural warm point: it is mounted in MainLayout, so it goes interactive on every
|
||||
/// page the player can play from.
|
||||
/// </summary>
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
await AnonId.EnsureLoadedAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose the player on unmount so the JS setInterval driving progress
|
||||
/// callbacks no longer holds a DotNetObjectReference into a destroyed
|
||||
|
||||
@@ -30,6 +30,7 @@ public partial class SharePopover : ComponentBase, IDisposable
|
||||
[Inject] public required NavigationManager Navigation { get; set; }
|
||||
[Inject] public required IJSRuntime JS { get; set; }
|
||||
[Inject] public required ShareTracker ShareTracker { get; set; }
|
||||
[Inject] public required IAnonIdProvider AnonId { get; set; }
|
||||
|
||||
private bool IsReleaseMode => ReleaseEntryKey is not null;
|
||||
|
||||
@@ -65,7 +66,15 @@ public partial class SharePopover : ComponentBase, IDisposable
|
||||
? EmbedSnippetBuilder.ForRelease(Navigation.BaseUri, ReleaseEntryKey!)
|
||||
: EmbedSnippetBuilder.ForTrack(Navigation.BaseUri, EntryKey!);
|
||||
|
||||
private void Toggle() => _open = !_open;
|
||||
private async Task Toggle()
|
||||
{
|
||||
_open = !_open;
|
||||
// Warm the anon-id cache when the popover opens (wave 16.3) so a copy-share fired moments later
|
||||
// reads a populated AnonId.Current. Idempotent and best-effort — if it fails the share simply
|
||||
// carries no anonId. Opening is interactive, so the localStorage interop is available here.
|
||||
if (_open)
|
||||
await AnonId.EnsureLoadedAsync();
|
||||
}
|
||||
|
||||
private void Close() => _open = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user