Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useSpreadsheetEquipments = () => {

const applyToAllTypes = useCallback(
(callback: (type: SpreadsheetEquipmentType) => void) => {
tablesDefinitions.map((tableDefinition) => tableDefinition.type).forEach((type) => callback(type));
new Set(tablesDefinitions.map((tableDefinition) => tableDefinition.type)).forEach((type) => callback(type));
},
[tablesDefinitions]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,24 @@ export const SpreadsheetContent = memo(

// Initial data loading for this type when the tab is opened
useEffect(() => {
if (active && nodesIds.length > 0 && Object.keys(equipments.equipmentsByNodeId).length === 0) {
if (
active &&
nodesIds.length > 0 &&
Object.keys(equipments.equipmentsByNodeId).length === 0 &&
// There is automatic re-fetch in several cases (tree node change, aliases modified, loading options changed) in useSpreadsheetEquipments hook
// then we want to make sure the active tab is not duplicating fetch during automatic operation.
!equipments.isFetching
) {
fetchNodesEquipmentData(tableDefinition?.type, new Set(nodesIds));
}
}, [active, nodesIds, equipments.equipmentsByNodeId, fetchNodesEquipmentData, tableDefinition?.type]);
}, [
active,
nodesIds,
equipments.equipmentsByNodeId,
fetchNodesEquipmentData,
tableDefinition?.type,
equipments.isFetching,
]);

const { onModelUpdated } = useGridCalculations(gridRef, tableDefinition.uuid, columns);

Expand Down
Loading