From 1d331b5759b28954023413bb6dcba45f1e1801aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Carr=C3=A8re?= Date: Sun, 8 Dec 2024 15:34:28 +0100 Subject: [PATCH] Previous messages selection bug fix. --- .../UI/Razor/Components/ChatMessage.razor | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/LM-Kit-Maestro/UI/Razor/Components/ChatMessage.razor b/LM-Kit-Maestro/UI/Razor/Components/ChatMessage.razor index 333ef06..465f865 100644 --- a/LM-Kit-Maestro/UI/Razor/Components/ChatMessage.razor +++ b/LM-Kit-Maestro/UI/Razor/Components/ChatMessage.razor @@ -264,32 +264,35 @@ { get => messageViewModel!; set - { - if (messageViewModel != null) - { - messageViewModel.PropertyChanged -= OnMessageViewModelPropertyChanged; - } - - messageViewModel = value; - messageViewModel.PropertyChanged += OnMessageViewModelPropertyChanged; - - if (messageViewModel.Sender == MessageSender.Assistant) - { - messageHtml = GenerateAssistantResponseHtml(messageViewModel.Text, messageViewModel.MessageInProgress); - } - - if (MessageViewModel.PreviousContent?.Count > 0) - { - HasMultipleResponses = true; - responseIndex = MessageViewModel.PreviousContent.Count; - } - else + { + if (messageViewModel != value) { - HasMultipleResponses = false; - responseIndex = 0; + if (messageViewModel != null) + { + messageViewModel.PropertyChanged -= OnMessageViewModelPropertyChanged; + } + + messageViewModel = value; + messageViewModel.PropertyChanged += OnMessageViewModelPropertyChanged; + + if (messageViewModel.Sender == MessageSender.Assistant) + { + messageHtml = GenerateAssistantResponseHtml(messageViewModel.Text, messageViewModel.MessageInProgress); + } + + if (MessageViewModel.PreviousContent?.Count > 0) + { + HasMultipleResponses = true; + responseIndex = MessageViewModel.PreviousContent.Count; + } + else + { + HasMultipleResponses = false; + responseIndex = 0; + } + + InvokeAsync(() => StateHasChanged()); } - - InvokeAsync(() => StateHasChanged()); } } #pragma warning restore BL0007