fix(top bar): a signed-out ON-AIR press starts sign-in instead of disabling the button
Reported: EDIT on + ON-AIR on, signed out → the button reads "Test Stream" and cannot be pressed. Cause: the primary button bound straight to StartTestCommand, whose CanExecute needs a connection. StartSession already routed signed-out ON-AIR to the sign-in flow; the test path bypassed it. The route is now explicit and pure: RouteFor(kind, connected) → SignIn | Record | Live | Test. The primary command calls SignInAsync for the SignIn route, BeginTestStream for Test, StartSession otherwise — so the label, the action and the sign-in fallback cannot drift apart. Pinned in SessionStartDecisionTests for both live and test, connected and not.
This commit is contained in:
@@ -188,11 +188,30 @@ public partial class MainViewModel : ViewModelBase
|
||||
|
||||
public string PrimaryStartButtonLabel => SessionStartDecision.LabelFor(PrimaryStartKind);
|
||||
|
||||
/// <summary>The button's action follows its label: Test runs the same go-live pipeline with
|
||||
/// `IsTestStream` set, Go Live runs it for real.</summary>
|
||||
public ICommand PrimaryStartCommand => PrimaryStartKind == SessionStartKind.Test
|
||||
? StartTestCommand
|
||||
: StartStreamCommand;
|
||||
private ICommand? _primaryStartCommand;
|
||||
|
||||
/// <summary>The button's action follows its label — and a signed-out ON-AIR press starts the
|
||||
/// SIGN-IN flow instead of disabling the control (which is what binding straight to
|
||||
/// <see cref="StartTestCommand"/> did: its CanExecute needs a connection, so the button the
|
||||
/// creator was told to press could not be pressed).</summary>
|
||||
public ICommand PrimaryStartCommand =>
|
||||
_primaryStartCommand ??= new RelayCommand(_ => StartFromPrimaryButton(), _ => ShowPrimaryStartButton);
|
||||
|
||||
private void StartFromPrimaryButton()
|
||||
{
|
||||
switch (SessionStartDecision.RouteFor(PrimaryStartKind, IsConnected))
|
||||
{
|
||||
case SessionStartDecision.Route.SignIn:
|
||||
_ = SignInAsync();
|
||||
return;
|
||||
case SessionStartDecision.Route.Test:
|
||||
BeginTestStream();
|
||||
return;
|
||||
default:
|
||||
StartSession();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The End button shows while recording OR live.</summary>
|
||||
public bool ShowEndStreamButton => IsLive || IsRecording;
|
||||
|
||||
Reference in New Issue
Block a user