From e573d0240bd4632fbe6838b9908837f1dbf58023 Mon Sep 17 00:00:00 2001 From: AssisrMatheus Date: Wed, 9 Mar 2022 15:00:11 -0300 Subject: [PATCH 1/3] fix: fixes a bug where submodule button isn't enabled when placing a module --- src/components/Providers/PlannerProvider/index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/Providers/PlannerProvider/index.tsx b/src/components/Providers/PlannerProvider/index.tsx index 7cf6e6c..cac374f 100644 --- a/src/components/Providers/PlannerProvider/index.tsx +++ b/src/components/Providers/PlannerProvider/index.tsx @@ -661,7 +661,8 @@ export const PlannerProvider: React.FC = ({ children, proj setState('Created'); if (projectModule.module.isMat) { - await handleUpsertProjectModule(projectModule, []); + // Purposefully do not await as we don't need it as dependency of anything + handleUpsertProjectModule(projectModule, []); } }, selectedModule: (projectModuleJson: string, childrenJson?: string) => { @@ -697,7 +698,8 @@ export const PlannerProvider: React.FC = ({ children, proj // Using this because putting the variable on the dependencies make the entire code not run. if (!projectModule.module.isMat && shouldCreateOrUpdate.current) { - await handleUpsertProjectModule(projectModule, childrenModules?.children || []); + // Purposefully do not await as we don't need it as dependency of anything + handleUpsertProjectModule(projectModule, childrenModules?.children || []); setProjectModule(undefined); setChildrenModules(undefined); shouldCreateOrUpdate.current = false; @@ -724,7 +726,9 @@ export const PlannerProvider: React.FC = ({ children, proj (x) => x.id !== projectModule.id || (childrenModules?.children || []).some((y) => y.id === x.id) ) ); - await handleDeleteProjectModule(projectModule, childrenModules?.children); + + // Purposefully do not await as we don't need it as dependency of anything + handleDeleteProjectModule(projectModule, childrenModules?.children); }, recalculatedExtensions: async (projectModuleJson: string, childrenJson: string) => { if (!finishedSetup) return; @@ -733,7 +737,8 @@ export const PlannerProvider: React.FC = ({ children, proj console.log('recalculatedExtensions: ', projectModule, childrenModules); - await handleUpsertProjectModule(projectModule, childrenModules.children); + // Purposefully do not await as we don't need it as dependency of anything + handleUpsertProjectModule(projectModule, childrenModules.children); }, unityReady: () => { if (!finishedSetup) { From 4469d35af3174bafe7ea3cc7a3be624190637b09 Mon Sep 17 00:00:00 2001 From: AssisrMatheus Date: Wed, 9 Mar 2022 15:13:22 -0300 Subject: [PATCH 2/3] fix: fixes bug when deleting edge module --- src/components/Providers/PlannerProvider/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Providers/PlannerProvider/index.tsx b/src/components/Providers/PlannerProvider/index.tsx index cac374f..2b52dff 100644 --- a/src/components/Providers/PlannerProvider/index.tsx +++ b/src/components/Providers/PlannerProvider/index.tsx @@ -714,7 +714,7 @@ export const PlannerProvider: React.FC = ({ children, proj setProjectModule((currProjectModule) => { // Only deselect if current project module is the same that it's deleting - if (projectModule.id === currProjectModule?.id) { + if (!projectModule.module.isEdge && projectModule.id === currProjectModule?.id) { setState('Deleted'); return undefined; } else { From c962c829d8c70c62f52c5fd6145ceaab95d7e425 Mon Sep 17 00:00:00 2001 From: AssisrMatheus Date: Wed, 9 Mar 2022 15:20:22 -0300 Subject: [PATCH 3/3] fix: fixes loading when downloading modules --- src/components/Providers/PlannerProvider/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Providers/PlannerProvider/index.tsx b/src/components/Providers/PlannerProvider/index.tsx index 2b52dff..b900225 100644 --- a/src/components/Providers/PlannerProvider/index.tsx +++ b/src/components/Providers/PlannerProvider/index.tsx @@ -257,7 +257,7 @@ export const PlannerProvider: React.FC = ({ children, proj const createModule = useCallback( (module: ModuleDataFragment, rulesJson: Record) => { - // setIsPending(true); + setIsPending(true); const parentNanoId = nanoid(); const moduleJson = { @@ -300,12 +300,12 @@ export const PlannerProvider: React.FC = ({ children, proj unityInstance.current?.SendMessage(UNITY_GAME_OBJECT, 'CreateModule', json); }, - [unityInstance] + [unityInstance, setIsPending] ); const createChildrenModule = useCallback( (module: ModuleDataFragment, rulesJson: Record) => { - // setIsPending(true); + setIsPending(true); const moduleJson = { nanoId: nanoid(), @@ -320,7 +320,7 @@ export const PlannerProvider: React.FC = ({ children, proj unityInstance.current?.SendMessage(UNITY_GAME_OBJECT, 'CreateChildrenModule', json); }, - [unityInstance, projectModule] + [unityInstance, projectModule, setIsPending] ); const setupDrawer = useCallback( @@ -655,7 +655,7 @@ export const PlannerProvider: React.FC = ({ children, proj console.log('createModule: ', projectModule, childrenModules); - // setIsPending(false); + setIsPending(false); setProjectModule((prevProjectModule) => updateProjectModuleState(projectModule, prevProjectModule)); setChildrenModules(childrenModules?.children); setState('Created'); @@ -672,7 +672,7 @@ export const PlannerProvider: React.FC = ({ children, proj console.log('selectedModule: ', projectModule, childrenModules); - // setIsPending(false); + setIsPending(false); setProjectModule((prevProjectModule) => updateProjectModuleState(projectModule, prevProjectModule)); setChildrenModules(childrenModules?.children); setState('Selected');