From 76e8c22815a7f524303a413beaf6f9488a2aa726 Mon Sep 17 00:00:00 2001 From: gramps Date: Wed, 4 Nov 2026 10:11:39 -0800 Subject: [PATCH] fix(ui): own private broadcast close-out dialog --- KeepBroadcastDialog.xaml.cs | 2 ++ ytLive.Tests/TestStreamTests.cs | 41 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/KeepBroadcastDialog.xaml.cs b/KeepBroadcastDialog.xaml.cs index f95faf7..4cc0706 100644 --- a/KeepBroadcastDialog.xaml.cs +++ b/KeepBroadcastDialog.xaml.cs @@ -11,6 +11,8 @@ public partial class KeepBroadcastDialog : Window public KeepBroadcastDialog(string title) { InitializeComponent(); + if (Application.Current?.MainWindow is { } owner && !ReferenceEquals(owner, this)) + Owner = owner; MessageText.Text = string.IsNullOrWhiteSpace(title) ? "Your private broadcast is on YouTube as a private video. Keep it, or delete it?" : $"\u201c{title}\u201d is on YouTube as a private video. Keep it, or delete it?"; diff --git a/ytLive.Tests/TestStreamTests.cs b/ytLive.Tests/TestStreamTests.cs index 9b199a8..6acf90e 100644 --- a/ytLive.Tests/TestStreamTests.cs +++ b/ytLive.Tests/TestStreamTests.cs @@ -69,6 +69,45 @@ public sealed class TestStreamTests _app.Run(RunWindow); } + [Fact] + public void KeepBroadcastPrompt_IsOwnedAndReturnsControlToTheMainWindow() + { + _app.Run(RunKeepBroadcastPrompt); + } + + private void RunKeepBroadcastPrompt() + { + var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-test-{Guid.NewGuid():N}.db"); + MainViewModel.LayoutPathOverride = tempDb; + MainWindow? window = null; + var previousMainWindow = Application.Current.MainWindow; + try + { + using (var schema = new LayoutStore(tempDb)) { } + SqliteConnection.ClearAllPools(); + + window = new MainWindow(); + Application.Current.MainWindow = window; + window.Show(); + window.UpdateLayout(); + + var dialog = new KeepBroadcastDialog("Test broadcast"); + Assert.Same(window, dialog.Owner); + dialog.Loaded += (_, _) => dialog.DialogResult = true; + Assert.True(dialog.ShowDialog()); + Assert.True(window.IsEnabled); + Assert.True(window.IsLoaded); + } + finally + { + if (window != null) window.Close(); + Application.Current.MainWindow = previousMainWindow; + MainViewModel.LayoutPathOverride = null; + SqliteConnection.ClearAllPools(); + try { File.Delete(tempDb); } catch { /* best-effort */ } + } + } + private void RunCoordinator() { var handler = new RecordingHandler(); @@ -212,4 +251,4 @@ public sealed class TestStreamTests try { File.Delete(tempDb); } catch { /* best-effort cleanup */ } } } -} \ No newline at end of file +}