mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-21 04:12:56 +00:00
Fixed reset item method by using a deep clone
This commit is contained in:
parent
93c5db8f98
commit
c4a56f969f
@ -42,7 +42,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
|
|||||||
public bool IsEditing { get; init; }
|
public bool IsEditing { get; init; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public List<ContentBlock> ExampleConversation { get; set; } = [];
|
public IReadOnlyCollection<ContentBlock> ExampleConversation { get; init; } = [];
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool AllowProfileUsage { get; set; } = true;
|
public bool AllowProfileUsage { get; set; } = true;
|
||||||
@ -62,7 +62,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
|
|||||||
private string dataEditingPreviousName = string.Empty;
|
private string dataEditingPreviousName = string.Empty;
|
||||||
private bool isInlineEditOnGoing;
|
private bool isInlineEditOnGoing;
|
||||||
|
|
||||||
private ContentBlock messageEntryBeforeEdit;
|
private ContentBlock? messageEntryBeforeEdit;
|
||||||
|
|
||||||
// We get the form reference from Blazor code to validate it manually:
|
// We get the form reference from Blazor code to validate it manually:
|
||||||
private MudForm form = null!;
|
private MudForm form = null!;
|
||||||
@ -154,11 +154,20 @@ public partial class ChatTemplateDialog : MSGComponentBase
|
|||||||
// When editing, we need to load the data:
|
// When editing, we need to load the data:
|
||||||
if(this.IsEditing)
|
if(this.IsEditing)
|
||||||
this.isInlineEditOnGoing = false;
|
this.isInlineEditOnGoing = false;
|
||||||
|
switch (element)
|
||||||
{
|
{
|
||||||
this.dataEditingPreviousName = this.DataName.ToLowerInvariant();
|
this.dataEditingPreviousName = this.DataName.ToLowerInvariant();
|
||||||
|
case ContentBlock block:
|
||||||
|
if (this.messageEntryBeforeEdit is null)
|
||||||
|
return; // No backup to restore from
|
||||||
|
|
||||||
|
block.Content = this.messageEntryBeforeEdit.Content?.DeepClone();
|
||||||
|
block.Role = this.messageEntryBeforeEdit.Role;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
this.StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
Loading…
Reference in New Issue
Block a user