Skip to content

Commit

Permalink
Make client mandatory in DataStory
Browse files Browse the repository at this point in the history
  • Loading branch information
ajthinking committed Sep 8, 2024
1 parent ea2b7d6 commit 3ee8be5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions packages/ui/src/components/DataStory/DataStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ export const DataStoryComponent = (
const [activityGroups, setActivityGroups] = useState<Activity[]>([]);

const { data: tree, loading: treeLoading, error: getTreeError } = useRequest(async() => {
return client
? await client.getTree({ path: LocalStorageKey })
: Promise.resolve([]);
return await client.getTree({ path: LocalStorageKey });
}, {
refreshDeps: [client],
manual: !client,
}, []);
handleRequestError(getTreeError);

Expand All @@ -47,12 +44,9 @@ export const DataStoryComponent = (
loading: nodeDescriptionsLoading,
error: getNodeDescriptionsError
} = useRequest(async() => {
return client
? await client.getNodeDescriptions({ path: LocalStorageKey })
: undefined;
return client.getNodeDescriptions({ path: LocalStorageKey })
}, {
refreshDeps: [client], // Will re-fetch if client changes
manual: !client, // If client is not available initially, do not run automatically
});
handleRequestError(getNodeDescriptionsError);

Expand All @@ -74,7 +68,7 @@ export const DataStoryComponent = (
}
updateTree(newTree);

client?.updateTree({ path: LocalStorageKey, tree: newTree });
client.updateTree({ path: LocalStorageKey, tree: newTree });
}, [diagramKey, tree]);

const handleClickExplorerNode = useCallback((node: NodeApi<Tree>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/DataStory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface ClientRunParams {
export type AcitvityBarType = 'node' | 'diagram' | 'settings' | 'explorer';

export type DataStoryProps = {
client?: WorkspaceApiClient,
client: WorkspaceApiClient,
server?: ServerConfig;
initDiagram?: Diagram | null;
hideControls?: boolean
Expand Down

0 comments on commit 3ee8be5

Please sign in to comment.