Skip to content

Commit

Permalink
Previous messages selection bug fix. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarrere authored Dec 8, 2024
1 parent cc6ea87 commit c7ee3b4
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions LM-Kit-Maestro/UI/Razor/Components/ChatMessage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c7ee3b4

Please sign in to comment.