Fixed tree item loading when ensuring bias workspace

This commit is contained in:
Thorsten Sommer 2024-10-27 20:20:37 +01:00
parent ce7029f019
commit 00a935b7cf
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -64,8 +64,8 @@ public partial class Workspaces : ComponentBase
// - When assigning the tree items to the MudTreeViewItem component, we must set the Value property to the value of the item // - When assigning the tree items to the MudTreeViewItem component, we must set the Value property to the value of the item
// //
await this.LoadTreeItems();
await this.EnsureBiasWorkspace(); await this.EnsureBiasWorkspace();
await this.LoadTreeItems();
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@ -252,7 +252,7 @@ public partial class Workspaces : ComponentBase
return result; return result;
} }
public async Task StoreChat(ChatThread chat) public async Task StoreChat(ChatThread chat, bool reloadTreeItems = true)
{ {
string chatDirectory; string chatDirectory;
if (chat.WorkspaceId == Guid.Empty) if (chat.WorkspaceId == Guid.Empty)
@ -272,7 +272,9 @@ public partial class Workspaces : ComponentBase
await File.WriteAllTextAsync(chatPath, JsonSerializer.Serialize(chat, JSON_OPTIONS), Encoding.UTF8); await File.WriteAllTextAsync(chatPath, JsonSerializer.Serialize(chat, JSON_OPTIONS), Encoding.UTF8);
// Reload the tree items: // Reload the tree items:
await this.LoadTreeItems(); if(reloadTreeItems)
await this.LoadTreeItems();
this.StateHasChanged(); this.StateHasChanged();
} }
@ -456,7 +458,6 @@ public partial class Workspaces : ComponentBase
Directory.CreateDirectory(workspacePath); Directory.CreateDirectory(workspacePath);
var workspaceNamePath = Path.Join(workspacePath, "name"); var workspaceNamePath = Path.Join(workspacePath, "name");
await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8); await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8);
await this.LoadTreeItems();
} }
private async Task DeleteWorkspace(string? workspacePath) private async Task DeleteWorkspace(string? workspacePath)