fix: decouple Stream Now label flag from re-entrancy guard
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
disabled="@_streamLoading"
|
disabled="@_streamLoading"
|
||||||
aria-busy="@_streamLoading.ToString().ToLowerInvariant()"
|
aria-busy="@_streamLoading.ToString().ToLowerInvariant()"
|
||||||
@onclick="StreamNow">
|
@onclick="StreamNow">
|
||||||
@if (_streamLoading)
|
@if (_findingTrack)
|
||||||
{
|
{
|
||||||
<span>Finding a track…</span>
|
<span>Finding a track…</span>
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
disabled="@_streamLoading"
|
disabled="@_streamLoading"
|
||||||
aria-busy="@_streamLoading.ToString().ToLowerInvariant()"
|
aria-busy="@_streamLoading.ToString().ToLowerInvariant()"
|
||||||
@onclick="StreamNowMobile">
|
@onclick="StreamNowMobile">
|
||||||
@if (_streamLoading)
|
@if (_findingTrack)
|
||||||
{
|
{
|
||||||
<span>Finding a track…</span>
|
<span>Finding a track…</span>
|
||||||
}
|
}
|
||||||
@@ -118,6 +118,7 @@
|
|||||||
|
|
||||||
private bool _mobileMenuOpen;
|
private bool _mobileMenuOpen;
|
||||||
private bool _streamLoading;
|
private bool _streamLoading;
|
||||||
|
private bool _findingTrack;
|
||||||
private string? _streamMessage;
|
private string? _streamMessage;
|
||||||
private CancellationTokenSource? _messageCts;
|
private CancellationTokenSource? _messageCts;
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@
|
|||||||
if (_streamLoading) return;
|
if (_streamLoading) return;
|
||||||
|
|
||||||
_streamLoading = true;
|
_streamLoading = true;
|
||||||
|
_findingTrack = true;
|
||||||
_streamMessage = null;
|
_streamMessage = null;
|
||||||
|
|
||||||
// Warm the AudioContext FIRST, inside the gesture's call stack and before the network
|
// Warm the AudioContext FIRST, inside the gesture's call stack and before the network
|
||||||
@@ -164,9 +166,10 @@
|
|||||||
if (closeMobileMenu)
|
if (closeMobileMenu)
|
||||||
_mobileMenuOpen = false;
|
_mobileMenuOpen = false;
|
||||||
|
|
||||||
// Track is found — clear the loading state immediately so the button
|
// Track is found — flip only the label flag so the button reverts to
|
||||||
// reverts to "Stream Now ▶" before the stream begins.
|
// "Stream Now ▶" before the stream begins, while _streamLoading stays true
|
||||||
_streamLoading = false;
|
// to keep the button disabled and the re-entrancy guard intact.
|
||||||
|
_findingTrack = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
if (PlayerService is not null)
|
if (PlayerService is not null)
|
||||||
@@ -179,6 +182,7 @@
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_streamLoading = false;
|
_streamLoading = false;
|
||||||
|
_findingTrack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user