diff --git a/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx b/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx index 95bdd46f5f..b7053eef19 100644 --- a/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx +++ b/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx @@ -117,6 +117,7 @@ import { isModificationsDeleteFinishedNotification, isModificationsUpdateFinishedNotification, isNodeDeletedNotification, + isSharedElementUpdateNotification, parseEventData, } from 'types/notification-types'; import { LccModificationDialog } from '../../../dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog'; @@ -802,6 +803,19 @@ const NetworkModificationNodeEditor = () => { } dofetchNetworkModifications(); } + + // a shared (referenced) composite modification pointed at by this node was edited + // elsewhere. Re-fetching the group hands NetworkModificationsTable a fresh + // `modifications` identity, which makes it force-refresh the resolved content of every + // expanded composite / reference row (fetchSubModificationsForExpandedRows(..., force)); + // a collapsed reference reloads its content the next time it is expanded. + if (isSharedElementUpdateNotification(eventData)) { + if (currentNodeIdRef.current !== eventData.headers.parentNode) { + return; + } + dofetchNetworkModifications(); + dofetchExcludedNetworkModifications(); + } }, [dofetchNetworkModifications, cleanClipboard, dofetchExcludedNetworkModifications] ); diff --git a/src/components/graph/menus/root-network/use-root-network-search-notifications.ts b/src/components/graph/menus/root-network/use-root-network-search-notifications.ts index 0865e1629e..2043169239 100644 --- a/src/components/graph/menus/root-network/use-root-network-search-notifications.ts +++ b/src/components/graph/menus/root-network/use-root-network-search-notifications.ts @@ -18,6 +18,7 @@ import { isNodeEditedNotification, isNodeSubTreeCreatedNotification, isRootNetworksUpdatedNotification, + isSharedElementUpdateNotification, } from 'types/notification-types'; type UseRootNetworkNotificationsProps = { @@ -39,7 +40,8 @@ export const useRootNetworkSearchNotifications = ({ const rootNetworksStatus = isRootNetworksUpdatedNotification(eventData); const networkModificationsStatus = isModificationsDeleteFinishedNotification(eventData) || - isModificationsUpdateFinishedNotification(eventData); + isModificationsUpdateFinishedNotification(eventData) || + isSharedElementUpdateNotification(eventData); const nodeDeleted = isNodeDeletedNotification(eventData); const nodeCreated = isNodeCreatedNotification(eventData); const nodeEdited = isNodeEditedNotification(eventData); diff --git a/src/types/notification-types.ts b/src/types/notification-types.ts index f22c0fae95..0698166492 100644 --- a/src/types/notification-types.ts +++ b/src/types/notification-types.ts @@ -41,6 +41,7 @@ export enum NotificationType { // Modifications MODIFICATIONS_UPDATE_FINISHED = 'UPDATE_FINISHED', MODIFICATIONS_DELETE_FINISHED = 'DELETE_FINISHED', + SHARED_ELEMENT_UPDATE = 'sharedElementUpdate', // Events EVENT_CRUD_FINISHED = 'EVENT_CRUD_FINISHED', @@ -279,6 +280,12 @@ interface ModificationsDeleteFinishedEventDataHeaders extends CommonStudyEventDa nodes: UUID[]; } +interface SharedElementUpdateEventDataHeaders extends CommonStudyEventDataHeaders { + updateType: NotificationType.SHARED_ELEMENT_UPDATE; + parentNode: UUID; + networkModificationUuids?: UUID[]; +} + interface EventCrudFinishedEventDataHeaders extends CommonStudyEventDataHeaders { updateType: NotificationType.EVENT_CRUD_FINISHED; parentNode: UUID; @@ -484,6 +491,11 @@ export interface ModificationsUpdateFinishedEventData extends CommonStudyEventDa payload: undefined; } +export interface SharedElementUpdateEventData extends CommonStudyEventData { + headers: SharedElementUpdateEventDataHeaders; + payload: undefined; +} + export interface ModificationsDeleteFinishedEventData extends CommonStudyEventData { headers: ModificationsDeleteFinishedEventDataHeaders; payload: undefined; @@ -674,6 +686,10 @@ export function isModificationsDeleteFinishedNotification( return notif.headers?.updateType === NotificationType.MODIFICATIONS_DELETE_FINISHED; } +export function isSharedElementUpdateNotification(notif: CommonStudyEventData): notif is SharedElementUpdateEventData { + return notif.headers?.updateType === NotificationType.SHARED_ELEMENT_UPDATE; +} + export function isIndexationStatusNotification(notif: CommonStudyEventData): notif is IndexationStatusEventData { return notif.headers?.updateType === NotificationType.INDEXATION_STATUS; }