Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danpriori committed Jul 1, 2024
1 parent 06309dd commit c48d6f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
18 changes: 0 additions & 18 deletions react-components/src/components/CacheProvider/AssetMappingCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export const Reveal3DResources = ({
[reveal3DModels]
);

console.log('Reveal3DResources instanceStyling', instanceStyling);

const { styledModels: styledCadModelOptions, modelMappingsIsFetched } = useCalculateCadStyling(
cadModelOptions,
instanceStyling?.filter(isCadAssetMappingStylingGroup) ?? EMPTY_ARRAY,
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuleAndEnabled>();
const [emptyRuleSelected, setEmptyRuleSelected] = useState<EmptyRuleForSelection>();
Expand Down Expand Up @@ -55,7 +55,6 @@ export const RuleBasedOutputsButton = ({

const onChange = useCallback(
(data: string | undefined): void => {

ruleInstances?.forEach((item) => {
if (item === undefined) return;
item.isEnabled = false;
Expand Down Expand Up @@ -83,8 +82,6 @@ export const RuleBasedOutputsButton = ({
if (onRuleSetStylingChanged !== undefined) onRuleSetStylingChanged(undefined);
}

if (callbackFunction !== undefined) callbackFunction(callbackLoaded);

setIsRuleLoading(true);

setEmptyRuleSelected(emptySelection);
Expand All @@ -93,17 +90,19 @@ export const RuleBasedOutputsButton = ({
[ruleInstances, onRuleSetStylingChanged, onRuleSetSelectedChanged]
);

const callbackLoaded = (isLoaded: boolean): void => {
setIsRuleLoading(!isLoaded);
};

const ruleSetStylingChanged = (
stylingGroups: AssetStylingGroupAndStyleIndex[] | undefined
): void => {
const assetStylingGroups = stylingGroups?.map((group) => group.assetStylingGroup);
if (onRuleSetStylingChanged !== undefined) onRuleSetStylingChanged(assetStylingGroups);
};

const callbackWhenIsLoaded = (isLoaded: boolean): void => {
setIsRuleLoading(!isLoaded);
};

if (onRuleSetStylingLoaded !== undefined) onRuleSetStylingLoaded(callbackWhenIsLoaded);

if (ruleInstances === undefined || ruleInstances.length === 0) {
return <></>;
}
Expand Down

0 comments on commit c48d6f6

Please sign in to comment.