Skip to content

Commit

Permalink
fix(DynamicScenes): fix bug to render empty scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
hwandersman authored and mumanity committed Jun 4, 2024
1 parent 3c03272 commit 2c25827
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('SceneLayers', () => {
await queryFunction();

expect(processQueries as jest.Mock).toBeCalledTimes(1);
expect(renderSceneNodesMock).toBeCalledTimes(0);
expect(renderSceneNodesMock).toBeCalledTimes(1);
expect(addMessagesMock).toBeCalledTimes(1);
});
});
15 changes: 9 additions & 6 deletions packages/scene-composer/src/components/SceneLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const SceneLayers: React.FC = () => {
const checkForSceneRootEntity = useCallback(async () => {
const sceneMetadataModule = getGlobalSettings().twinMakerSceneMetadataModule;
if (sceneMetadataModule) {
if (!(await checkIfEntityExists(sceneRootEntityId, sceneMetadataModule))) {
const doesRootEntityExist = await checkIfEntityExists(sceneRootEntityId, sceneMetadataModule);
if (!doesRootEntityExist) {
addMessages([
{
category: DisplayMessageCategory.Error,
Expand All @@ -54,13 +55,15 @@ export const SceneLayers: React.FC = () => {
}, [sceneRootEntityId, addMessages, formatMessage]);

useEffect(() => {
if (nodes.data) {
if (nodes.data.length > 0) {
const doAsync = async () => {
if (nodes.data) {
if (nodes.data.length === 0) {
await checkForSceneRootEntity();
}
renderSceneNodes(nodes.data);
} else {
checkForSceneRootEntity();
}
}
};
doAsync();
}, [nodes.data, renderSceneNodes, checkForSceneRootEntity]);

return <></>;
Expand Down

0 comments on commit 2c25827

Please sign in to comment.