From c48d6f602ff746194ab2e306d12ac599cee9868e Mon Sep 17 00:00:00 2001 From: Daniel Priori Date: Mon, 1 Jul 2024 11:56:48 +0200 Subject: [PATCH] cleanup --- .../CacheProvider/AssetMappingCache.ts | 18 ------------------ .../Reveal3DResources/Reveal3DResources.tsx | 6 ------ .../RevealToolbar/RuleBasedOutputsButton.tsx | 17 ++++++++--------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/react-components/src/components/CacheProvider/AssetMappingCache.ts b/react-components/src/components/CacheProvider/AssetMappingCache.ts index b1c96be3631..c2155489068 100644 --- a/react-components/src/components/CacheProvider/AssetMappingCache.ts +++ b/react-components/src/components/CacheProvider/AssetMappingCache.ts @@ -93,8 +93,6 @@ export class AssetMappingCache { const chunkSize = Math.round(assetIdsList.length / amountOfChunks); const listChunks = chunk(assetIdsList, chunkSize); - console.log('chunk listChunks', listChunks.length, listChunks); - const allAssetMappingsReturned = listChunks.map(async (itemChunk) => { const assetMappings = await this.getAssetMappingsForAssetIds(modelId, revisionId, itemChunk); return assetMappings; @@ -138,8 +136,6 @@ export class AssetMappingCache { revisionId ); - console.log('chunk NODE IDS', chunkNotInCache, chunkInCache); - const nodes = await fetchNodesForNodeIds(modelId, revisionId, chunkNotInCache, this._sdk); const allNodes = chunkInCache.concat(nodes); return allNodes; @@ -166,14 +162,11 @@ export class AssetMappingCache { return; } assetMappingsPerModel.forEach(async (modelMapping) => { - console.log(' assetMappings modelMapping ', modelMapping); - modelMapping.assetMappings.forEach(async (item) => { const key = modelRevisionNodesAssetsToKey(modelId, revisionId, [item.assetId]); await this.setAssetMappingsCacheItem(key, item); }); }); - console.log(' assetMappings cache', this._assetIdsToAssetMappings); } public async getAssetMappingsForModel( @@ -333,7 +326,6 @@ export class AssetMappingCache { if (cachedResult === undefined) { this.setItemCacheResult(filterType, key, cachedResult); } - // console.log('chunk fetchAssetMappingsRequest key, cachedResult ', key, cachedResult); }); return assetMapping3D.filter(isValidAssetMapping); @@ -414,12 +406,6 @@ export class AssetMappingCache { notCachedNodeIds, 'nodeIds' ); - console.log( - 'chunk getAssetMappingsForNodes chunkNotInCache, chunkInCache ', - chunkNotInCache, - chunkInCache, - nodeIds - ); const allAssetMappings = chunkInCache.concat(assetMappings); return allAssetMappings; @@ -437,10 +423,6 @@ export class AssetMappingCache { 'assetIds' ); - console.log('chunk assetIds modelId', modelId, assetIds); - console.log('chunk chunkInCache modelId ', modelId, chunkInCache); - console.log('chunk chunkNotInCache modelId ', modelId, chunkNotInCache); - const notCachedAssetIds: number[] = chunkNotInCache; const assetMappings = await this.fetchAndCacheMappingsForIds( diff --git a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx index 4d1b06abc57..d1797f2732e 100644 --- a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx +++ b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx @@ -82,8 +82,6 @@ export const Reveal3DResources = ({ [reveal3DModels] ); - console.log('Reveal3DResources instanceStyling', instanceStyling); - const { styledModels: styledCadModelOptions, modelMappingsIsFetched } = useCalculateCadStyling( cadModelOptions, instanceStyling?.filter(isCadAssetMappingStylingGroup) ?? EMPTY_ARRAY, @@ -124,16 +122,12 @@ export const Reveal3DResources = ({ if (numModelsLoaded.current === expectedTotalLoadCount && onResourcesAdded !== undefined) { onResourcesAdded(); } - - console.log('Loaded models:', numModelsLoaded.current, 'Expected:', expectedTotalLoadCount); }; useEffect(() => { if (modelMappingsIsFetched && onCallback !== undefined) { - console.log('LOADING modelMappingsIsFetched', modelMappingsIsFetched); onCallback(modelMappingsIsFetched); } - console.log('LOADING modelMappingsIsFetched onCallback ', modelMappingsIsFetched, onCallback); }, [modelMappingsIsFetched, onCallback]); return ( diff --git a/react-components/src/components/RevealToolbar/RuleBasedOutputsButton.tsx b/react-components/src/components/RevealToolbar/RuleBasedOutputsButton.tsx index 2eb70b2da76..2fb56490b4b 100644 --- a/react-components/src/components/RevealToolbar/RuleBasedOutputsButton.tsx +++ b/react-components/src/components/RevealToolbar/RuleBasedOutputsButton.tsx @@ -22,12 +22,12 @@ import { RuleBasedSelectionItem } from '../RuleBasedOutputs/components/RuleBased type RuleBasedOutputsButtonProps = { onRuleSetStylingChanged?: (stylings: AssetStylingGroup[] | undefined) => void; onRuleSetSelectedChanged?: (ruleSet: RuleAndEnabled | undefined) => void; - callbackFunction?: (callback: (isLoaded: boolean) => void) => void; + onRuleSetStylingLoaded?: (callback: (isLoaded: boolean) => void) => void; }; export const RuleBasedOutputsButton = ({ onRuleSetStylingChanged, onRuleSetSelectedChanged, - callbackFunction + onRuleSetStylingLoaded }: RuleBasedOutputsButtonProps): ReactElement => { const [currentRuleSetEnabled, setCurrentRuleSetEnabled] = useState(); const [emptyRuleSelected, setEmptyRuleSelected] = useState(); @@ -55,7 +55,6 @@ export const RuleBasedOutputsButton = ({ const onChange = useCallback( (data: string | undefined): void => { - ruleInstances?.forEach((item) => { if (item === undefined) return; item.isEnabled = false; @@ -83,8 +82,6 @@ export const RuleBasedOutputsButton = ({ if (onRuleSetStylingChanged !== undefined) onRuleSetStylingChanged(undefined); } - if (callbackFunction !== undefined) callbackFunction(callbackLoaded); - setIsRuleLoading(true); setEmptyRuleSelected(emptySelection); @@ -93,10 +90,6 @@ export const RuleBasedOutputsButton = ({ [ruleInstances, onRuleSetStylingChanged, onRuleSetSelectedChanged] ); - const callbackLoaded = (isLoaded: boolean): void => { - setIsRuleLoading(!isLoaded); - }; - const ruleSetStylingChanged = ( stylingGroups: AssetStylingGroupAndStyleIndex[] | undefined ): void => { @@ -104,6 +97,12 @@ export const RuleBasedOutputsButton = ({ if (onRuleSetStylingChanged !== undefined) onRuleSetStylingChanged(assetStylingGroups); }; + const callbackWhenIsLoaded = (isLoaded: boolean): void => { + setIsRuleLoading(!isLoaded); + }; + + if (onRuleSetStylingLoaded !== undefined) onRuleSetStylingLoaded(callbackWhenIsLoaded); + if (ruleInstances === undefined || ruleInstances.length === 0) { return <>; }