From 262492b628b00de5a4f3003f0afce12a31184d89 Mon Sep 17 00:00:00 2001 From: Yash Rastogi Date: Sat, 11 Apr 2026 17:44:17 -0400 Subject: [PATCH] fix(workspace): resolve indefinite loading state on edit page (ref Sentinent-AI/Sentinent#24) --- .../components/workspace/edit-workspace.html | 2 +- .../components/workspace/edit-workspace.ts | 38 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/app/components/workspace/edit-workspace.html b/src/app/components/workspace/edit-workspace.html index fc328b8..dea5561 100644 --- a/src/app/components/workspace/edit-workspace.html +++ b/src/app/components/workspace/edit-workspace.html @@ -24,7 +24,7 @@

Edit Workspace

Loading workspace... -
+
{ @@ -35,13 +37,24 @@ export class EditWorkspaceComponent implements OnInit { } loadWorkspace(id: string): void { - this.workspaceService.getWorkspace(id).subscribe(workspace => { - this.isLoading = false; - if (workspace) { - this.name = workspace.name; - this.description = workspace.description || ''; - } else { - this.error = 'Workspace not found'; + this.workspaceService.getWorkspace(id).subscribe({ + next: workspace => { + this.isLoading = false; + if (workspace) { + this.hasWorkspace = true; + this.name = workspace.name; + this.description = workspace.description || ''; + } else { + this.hasWorkspace = false; + this.error = 'Workspace not found'; + } + this.cdr.detectChanges(); + }, + error: () => { + this.isLoading = false; + this.hasWorkspace = false; + this.error = 'Unable to load workspace. Please try again.'; + this.cdr.detectChanges(); } }); } @@ -57,7 +70,14 @@ export class EditWorkspaceComponent implements OnInit { this.error = ''; this.workspaceService.updateWorkspace(this.workspaceId, trimmedName, this.description.trim()).subscribe({ - next: () => this.router.navigate(['/dashboard']), + next: (workspace) => { + if (workspace) { + this.router.navigate(['/dashboard']); + } else { + this.error = 'Workspace not found.'; + this.isSubmitting = false; + } + }, error: () => { this.error = 'Unable to update workspace. Please try again.'; this.isSubmitting = false;