Skip to content

Commit

Permalink
feat: add judgement when workspaceList is empty
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Aug 9, 2023
1 parent 2579883 commit 384449d
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/core/public/workspace/workspaces_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,27 @@ export class WorkspacesClient {

combineLatest([this.workspaceList$, this.currentWorkspaceId$]).subscribe(
([workspaceList, currentWorkspaceId]) => {
const currentWorkspace = this.findWorkspace([workspaceList, currentWorkspaceId]);
if (workspaceList.length) {
const currentWorkspace = this.findWorkspace([workspaceList, currentWorkspaceId]);

/**
* Do a simple idempotent verification here
*/
if (!isEqual(currentWorkspace, this.currentWorkspace$.getValue())) {
this.currentWorkspace$.next(currentWorkspace);
}

if (currentWorkspaceId && !currentWorkspace?.id) {
/**
* Current workspace is staled
* Do a simple idempotent verification here
*/
this.currentWorkspaceId$.error({
reason: WORKSPACE_ERROR_REASON_MAP.WORKSPACE_STALED,
});
this.currentWorkspace$.error({
reason: WORKSPACE_ERROR_REASON_MAP.WORKSPACE_STALED,
});
if (!isEqual(currentWorkspace, this.currentWorkspace$.getValue())) {
this.currentWorkspace$.next(currentWorkspace);
}

if (currentWorkspaceId && !currentWorkspace?.id) {
/**
* Current workspace is staled
*/
this.currentWorkspaceId$.error({
reason: WORKSPACE_ERROR_REASON_MAP.WORKSPACE_STALED,
});
this.currentWorkspace$.error({
reason: WORKSPACE_ERROR_REASON_MAP.WORKSPACE_STALED,
});
}
}
}
);
Expand Down

0 comments on commit 384449d

Please sign in to comment.