Skip to content

Commit

Permalink
fix(react-components): various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Aug 13, 2024
1 parent d61d0bb commit 93ec1d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,18 @@ export class RevisionFdmNodeCache {
mappingConnections: FdmCadConnection[],
nodes: Node3D[]
): Array<{ connection: FdmCadConnection; treeIndex: TreeIndex }> {
return mappingConnections.map((connection) => {
return mappingConnections.reduce((acc, connection) => {
const nodeInConnection = nodes.find((node) => node.id === connection.nodeId);

assert(nodeInConnection !== undefined);
if (nodeInConnection !== undefined) {
acc.push({
connection,
treeIndex: nodeInConnection.treeIndex
});
}

return {
connection,
treeIndex: nodeInConnection.treeIndex
};
});
return acc;
}, new Array<{ connection: FdmCadConnection; treeIndex: TreeIndex }>());
}

private async getMappingConnectionsForAncestors(
Expand Down
2 changes: 1 addition & 1 deletion react-components/src/data-providers/FdmSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function hoistInstanceProperties(
});
}

function makeSureNonEmptyFilterForRequest(
export function makeSureNonEmptyFilterForRequest(
filter: InstanceFilter | undefined
): InstanceFilter | undefined {
return filter !== undefined && Object.keys(filter).length === 0 ? undefined : filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
* Copyright 2024 Cognite AS
*/
import { type AddModelOptions } from '@cognite/reveal';
import { type InstanceFilter, type Query, type Source } from '../FdmSDK';
import {
makeSureNonEmptyFilterForRequest,
type InstanceFilter,
type Query,
type Source
} from '../FdmSDK';
import { SYSTEM_3D_EDGE_SOURCE } from './dataModels';

export function createMappedEquipmentQuery(
Expand All @@ -12,6 +17,8 @@ export function createMappedEquipmentQuery(
limit: number = 10000,
cursors?: Record<string, string>
): Query {
instanceFilter = makeSureNonEmptyFilterForRequest(instanceFilter);

return {
with: {
mapped_edges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const useMappingsForAssetIds = (
nextCursor.model.revisionId === model.revisionId
)?.cursor;

if (nextCursor === undefined) {
if (nextCursor === undefined || assetIds.length === 0) {
return { mappings: { items: [] }, model };
}

Expand Down

0 comments on commit 93ec1d6

Please sign in to comment.