@@ -1567,26 +1567,24 @@ export const reducer = createReducer(initialState, (builder) => {
1567
1567
1568
1568
builder . addCase ( DELETE_EQUIPMENTS , ( state , action : DeleteEquipmentsAction ) => {
1569
1569
action . equipments . forEach ( ( { equipmentType : equipmentToDeleteType , equipmentId : equipmentToDeleteId } ) => {
1570
- if ( state . spreadsheetNetwork [ equipmentToDeleteType ] ?. equipmentsByNodeId [ action . nodeId ] ) {
1571
- // in case of voltage level deletion, we need to update the linked substation which contains a list of its voltage levels
1572
- if ( equipmentToDeleteType === SpreadsheetEquipmentType . VOLTAGE_LEVEL ) {
1573
- const currentSubstations = state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ]
1574
- . equipmentsByNodeId [ action . nodeId ] as Record < string , Substation > | null ;
1575
- if ( currentSubstations != null ) {
1576
- state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ] . equipmentsByNodeId [
1577
- action . nodeId
1578
- ] = updateSubstationAfterVLDeletion ( currentSubstations , equipmentToDeleteId ) ;
1579
- }
1580
- } else if (
1581
- // If we delete a line or a two windings transformer we also have to delete it from branch type
1582
- ( equipmentToDeleteType === SpreadsheetEquipmentType . LINE ||
1583
- SpreadsheetEquipmentType . TWO_WINDINGS_TRANSFORMER ) &&
1584
- state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] . equipmentsByNodeId [ action . nodeId ]
1585
- ) {
1586
- delete state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] . equipmentsByNodeId [ action . nodeId ] [
1587
- equipmentToDeleteId
1588
- ] ;
1570
+ if (
1571
+ // If we delete a line or a two windings transformer we also have to delete it from branch type
1572
+ ( equipmentToDeleteType === SpreadsheetEquipmentType . LINE ||
1573
+ equipmentToDeleteType === SpreadsheetEquipmentType . TWO_WINDINGS_TRANSFORMER ) &&
1574
+ state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] ?. equipmentsByNodeId [ action . nodeId ]
1575
+ ) {
1576
+ delete state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] . equipmentsByNodeId [ action . nodeId ] [
1577
+ equipmentToDeleteId
1578
+ ] ;
1579
+ } else if ( equipmentToDeleteType === SpreadsheetEquipmentType . VOLTAGE_LEVEL ) {
1580
+ const currentSubstations = state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ]
1581
+ . equipmentsByNodeId [ action . nodeId ] as Record < string , Substation > | null ;
1582
+ if ( currentSubstations != null ) {
1583
+ state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ] . equipmentsByNodeId [ action . nodeId ] =
1584
+ updateSubstationAfterVLDeletion ( currentSubstations , equipmentToDeleteId ) ;
1589
1585
}
1586
+ }
1587
+ if ( state . spreadsheetNetwork [ equipmentToDeleteType ] ?. equipmentsByNodeId [ action . nodeId ] ) {
1590
1588
delete state . spreadsheetNetwork [ equipmentToDeleteType ] . equipmentsByNodeId [ action . nodeId ] [
1591
1589
equipmentToDeleteId
1592
1590
] ;
0 commit comments