diff --git a/src/RemoteViewer.Client/Services/Dialogs/AvaloniaDialogService.cs b/src/RemoteViewer.Client/Services/Dialogs/AvaloniaDialogService.cs index a52193a..a551059 100644 --- a/src/RemoteViewer.Client/Services/Dialogs/AvaloniaDialogService.cs +++ b/src/RemoteViewer.Client/Services/Dialogs/AvaloniaDialogService.cs @@ -88,7 +88,8 @@ public IWindowHandle ShowChatWindow(ChatViewModel viewModel) { DataContext = viewModel }; - window.ShowAndActivate(); + window.Show(); + window.Activate(); return new WindowHandle(window); }); } diff --git a/src/RemoteViewer.Client/Views/Chat/ChatView.axaml.cs b/src/RemoteViewer.Client/Views/Chat/ChatView.axaml.cs index a62cdb9..0221135 100644 --- a/src/RemoteViewer.Client/Views/Chat/ChatView.axaml.cs +++ b/src/RemoteViewer.Client/Views/Chat/ChatView.axaml.cs @@ -8,7 +8,6 @@ namespace RemoteViewer.Client.Views.Chat; public partial class ChatView : Window { private ChatViewModel? _viewModel; - private bool _forceClose; public ChatView() { @@ -18,23 +17,6 @@ public ChatView() this.Deactivated += this.OnDeactivated; } - public void ForceClose() - { - this._forceClose = true; - this.Close(); - } - - public void ShowAndActivate() - { - this.Show(); - - // Restore from minimized state if needed - if (this.WindowState == WindowState.Minimized) - this.WindowState = WindowState.Normal; - - this.Activate(); - } - private void OnDataContextChanged(object? sender, EventArgs e) { if (this._viewModel is not null) @@ -77,23 +59,12 @@ protected override void OnClosing(WindowClosingEventArgs e) { base.OnClosing(e); - if (this._forceClose) + if (this._viewModel is { } vm) { - // Dispose ViewModel and cleanup - if (this._viewModel is { } vm) - { - vm.Messages.CollectionChanged -= this.Messages_CollectionChanged; - vm.Dispose(); - } - return; + vm.Messages.CollectionChanged -= this.Messages_CollectionChanged; + vm.IsOpen = false; + vm.Dispose(); } - - // Hide instead of close to preserve state - e.Cancel = true; - this.Hide(); - - if (this._viewModel is { } vm2) - vm2.IsOpen = false; } private void Messages_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)