From b3411f921875da202bc40ac581c46a364543419a Mon Sep 17 00:00:00 2001 From: Christian <6939810+chkr1011@users.noreply.github.com> Date: Thu, 19 Sep 2024 21:23:16 +0200 Subject: [PATCH] Fix crashes when selecting items in Inflight and TopicExplorer pages (#101) * Use content presenter in inflight page for selected item. * Fix race condition in topic explorer. --- Source/Common/ViewLocator.cs | 2 +- Source/Pages/Inflight/InflightPageItemViewModel.cs | 2 +- Source/Pages/Inflight/InflightPageView.axaml | 13 ++++++++++--- Source/Pages/Inflight/InflightPageViewModel.cs | 8 -------- .../Pages/TopicExplorer/TopicExplorerItemView.axaml | 12 +++++++++--- Source/mqttMultimeter.sln.DotSettings | 1 + 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Source/Common/ViewLocator.cs b/Source/Common/ViewLocator.cs index ccc1410..c8529c8 100644 --- a/Source/Common/ViewLocator.cs +++ b/Source/Common/ViewLocator.cs @@ -15,7 +15,7 @@ public Control Build(object? viewModel) { return new TextBlock(); } - + var viewModelTypeName = viewModel.GetType().FullName!; if (!_viewTypeCache.TryGetValue(viewModelTypeName, out var viewType)) diff --git a/Source/Pages/Inflight/InflightPageItemViewModel.cs b/Source/Pages/Inflight/InflightPageItemViewModel.cs index c9eb96a..0d61cab 100644 --- a/Source/Pages/Inflight/InflightPageItemViewModel.cs +++ b/Source/Pages/Inflight/InflightPageItemViewModel.cs @@ -18,7 +18,7 @@ public InflightPageItemViewModel(MqttApplicationMessage message) } else { - Payload = Array.Empty(); + Payload = []; } Length = Payload.Length; diff --git a/Source/Pages/Inflight/InflightPageView.axaml b/Source/Pages/Inflight/InflightPageView.axaml index c406f19..d341983 100644 --- a/Source/Pages/Inflight/InflightPageView.axaml +++ b/Source/Pages/Inflight/InflightPageView.axaml @@ -63,7 +63,7 @@ @@ -139,8 +139,15 @@ Content="Selected message" /> - + + + + + + + + diff --git a/Source/Pages/Inflight/InflightPageViewModel.cs b/Source/Pages/Inflight/InflightPageViewModel.cs index 4f5ac34..c813705 100644 --- a/Source/Pages/Inflight/InflightPageViewModel.cs +++ b/Source/Pages/Inflight/InflightPageViewModel.cs @@ -29,8 +29,6 @@ public sealed class InflightPageViewModel : BasePageViewModel string? _filterText; bool _isRecordingEnabled = true; - InflightPageItemViewModel? _selectedItem; - public InflightPageViewModel(MqttClientService mqttClientService, InflightPageItemExportService exportService) { _mqttClientService = mqttClientService ?? throw new ArgumentNullException(nameof(mqttClientService)); @@ -64,12 +62,6 @@ public bool IsRecordingEnabled public ReadOnlyObservableCollection Items => _items; - public InflightPageItemViewModel? SelectedItem - { - get => _selectedItem; - set => this.RaiseAndSetIfChanged(ref _selectedItem, value); - } - public Task AppendMessage(MqttApplicationMessage message) { if (message == null) diff --git a/Source/Pages/TopicExplorer/TopicExplorerItemView.axaml b/Source/Pages/TopicExplorer/TopicExplorerItemView.axaml index a5ea0d5..c6ca286 100644 --- a/Source/Pages/TopicExplorer/TopicExplorerItemView.axaml +++ b/Source/Pages/TopicExplorer/TopicExplorerItemView.axaml @@ -34,6 +34,7 @@ @@ -98,9 +99,14 @@ Classes="grid_splitter_vertical" /> - + + + + + + + - \ No newline at end of file diff --git a/Source/mqttMultimeter.sln.DotSettings b/Source/mqttMultimeter.sln.DotSettings index 6ddae50..05195b2 100644 --- a/Source/mqttMultimeter.sln.DotSettings +++ b/Source/mqttMultimeter.sln.DotSettings @@ -243,6 +243,7 @@ True True True + True True True True