@@ -58,11 +58,17 @@ export function useUpdateEquipmentsOnNotification(nodeAliases: NodeAlias[] | und
58
58
}
59
59
60
60
if ( impactedSubstationsIds . length > 0 && studyUuid && currentRootNetworkUuid ) {
61
- fetchAllEquipments ( studyUuid , nodeUuid , currentRootNetworkUuid , impactedSubstationsIds ) . then (
62
- ( values ) => {
61
+ fetchAllEquipments ( studyUuid , nodeUuid , currentRootNetworkUuid , impactedSubstationsIds )
62
+ . then ( ( values ) => {
63
63
dispatch ( updateEquipments ( values , nodeUuid ) ) ;
64
- }
65
- ) ;
64
+ } )
65
+ . catch ( ( error : unknown ) => {
66
+ console . warn (
67
+ `Failed to update spreadsheet equipments on notification, it will be reset` ,
68
+ error
69
+ ) ;
70
+ dispatch ( resetEquipments ( ) ) ;
71
+ } ) ;
66
72
}
67
73
68
74
if ( deletedEquipments . length > 0 ) {
@@ -105,17 +111,22 @@ export function useUpdateEquipmentsOnNotification(nodeAliases: NodeAlias[] | und
105
111
currentRootNetworkUuid === eventRootNetworkUuid &&
106
112
builtNodesIds . has ( eventNodeUuid )
107
113
) {
108
- const networkImpacts = JSON . parse ( eventData . payload ) as NetworkImpactsInfos ;
109
- updateEquipmentsLocal (
110
- eventNodeUuid ,
111
- networkImpacts . impactedSubstationsIds ,
112
- networkImpacts . deletedEquipments ,
113
- networkImpacts . impactedElementTypes ?? [ ]
114
- ) ;
114
+ try {
115
+ const networkImpacts = JSON . parse ( eventData . payload ) as NetworkImpactsInfos ;
116
+ updateEquipmentsLocal (
117
+ eventNodeUuid ,
118
+ networkImpacts . impactedSubstationsIds ,
119
+ networkImpacts . deletedEquipments ,
120
+ networkImpacts . impactedElementTypes ?? [ ]
121
+ ) ;
122
+ } catch ( error : unknown ) {
123
+ console . warn ( `Something failed during spreadsheet update, it will be reset` , error ) ;
124
+ dispatch ( resetEquipments ( ) ) ;
125
+ }
115
126
}
116
127
}
117
128
} ,
118
- [ builtNodesIds , currentRootNetworkUuid , studyUuid , updateEquipmentsLocal ]
129
+ [ builtNodesIds , currentRootNetworkUuid , dispatch , studyUuid , updateEquipmentsLocal ]
119
130
) ;
120
131
121
132
useNotificationsListener ( NotificationsUrlKeys . STUDY , {
0 commit comments