From 5f8efdef05dfe250f16b7811f819e7f8d24da72e Mon Sep 17 00:00:00 2001 From: John Obelenus Date: Wed, 14 Aug 2024 14:23:26 -0400 Subject: [PATCH] Renamed connection_created to connection_upserted, following InferredEdge pattern. We can use this to send to_delete & ChangeStatus over the wire --- app/web/src/store/components.store.ts | 2 +- app/web/src/store/realtime/realtime_events.ts | 2 +- lib/dal/src/component.rs | 19 ++++--------------- lib/dal/src/ws_event.rs | 2 +- .../service/diagram/create_connection.rs | 2 +- .../server/service/diagram/paste_component.rs | 2 +- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/app/web/src/store/components.store.ts b/app/web/src/store/components.store.ts index 9b845d21ba..4b299874b0 100644 --- a/app/web/src/store/components.store.ts +++ b/app/web/src/store/components.store.ts @@ -1674,7 +1674,7 @@ export const useComponentsStore = (forceChangeSetId?: ChangeSetId) => { }, }, { - eventType: "ConnectionCreated", + eventType: "ConnectionUpserted", callback: (edge, metadata) => { // If the component that updated wasn't in this change set, // don't update diff --git a/app/web/src/store/realtime/realtime_events.ts b/app/web/src/store/realtime/realtime_events.ts index 1e1a236937..fee80fa393 100644 --- a/app/web/src/store/realtime/realtime_events.ts +++ b/app/web/src/store/realtime/realtime_events.ts @@ -190,7 +190,7 @@ export type WsEventPayloadMap = { changeSetId: string; edges: RawEdge[]; }; - ConnectionCreated: RawEdge; + ConnectionUpserted: RawEdge; ConnectionDeleted: { fromComponentId: string; toComponentId: string; diff --git a/lib/dal/src/component.rs b/lib/dal/src/component.rs index 6faec82ce9..1b2a89a803 100644 --- a/lib/dal/src/component.rs +++ b/lib/dal/src/component.rs @@ -3745,7 +3745,7 @@ impl Component { &finalized_new_component, ChangeStatus::Added, )?; - WsEvent::connection_created(ctx, edge) + WsEvent::connection_upserted(ctx, edge) .await? .publish_on_commit(ctx) .await?; @@ -3778,7 +3778,7 @@ impl Component { &to_component, ChangeStatus::Added, )?; - WsEvent::connection_created(ctx, edge) + WsEvent::connection_upserted(ctx, edge) .await? .publish_on_commit(ctx) .await?; @@ -4135,17 +4135,6 @@ pub struct ComponentDeletedPayload { change_set_id: ChangeSetId, } -#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct ConnectionCreatedPayload { - from_component_id: ComponentId, - to_component_id: ComponentId, - from_socket_id: OutputSocketId, - to_socket_id: InputSocketId, - change_set_id: ChangeSetId, - to_delete: bool, -} - #[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct ConnectionDeletedPayload { @@ -4306,11 +4295,11 @@ impl WsEvent { .await } - pub async fn connection_created( + pub async fn connection_upserted( ctx: &DalContext, edge: SummaryDiagramEdge, ) -> WsEventResult { - WsEvent::new(ctx, WsPayload::ConnectionCreated(edge)).await + WsEvent::new(ctx, WsPayload::ConnectionUpserted(edge)).await } pub async fn connection_deleted( diff --git a/lib/dal/src/ws_event.rs b/lib/dal/src/ws_event.rs index 4e6a71d453..4dd956c90c 100644 --- a/lib/dal/src/ws_event.rs +++ b/lib/dal/src/ws_event.rs @@ -85,8 +85,8 @@ pub enum WsPayload { ComponentDeleted(ComponentDeletedPayload), ComponentUpdated(ComponentUpdatedPayload), ComponentUpgraded(ComponentUpgradedPayload), - ConnectionCreated(SummaryDiagramEdge), ConnectionDeleted(ConnectionDeletedPayload), + ConnectionUpserted(SummaryDiagramEdge), Cursor(CursorPayload), FuncArgumentsSaved(FuncWsEventPayload), FuncCodeSaved(FuncWsEventCodeSaved), diff --git a/lib/sdf-server/src/server/service/diagram/create_connection.rs b/lib/sdf-server/src/server/service/diagram/create_connection.rs index 3832b4de81..35d209a911 100644 --- a/lib/sdf-server/src/server/service/diagram/create_connection.rs +++ b/lib/sdf-server/src/server/service/diagram/create_connection.rs @@ -79,7 +79,7 @@ pub async fn create_connection( &to_component, ChangeStatus::Added, )?; - WsEvent::connection_created(&ctx, edge) + WsEvent::connection_upserted(&ctx, edge) .await? .publish_on_commit(&ctx) .await?; diff --git a/lib/sdf-server/src/server/service/diagram/paste_component.rs b/lib/sdf-server/src/server/service/diagram/paste_component.rs index 40987ee373..64487ca9ee 100644 --- a/lib/sdf-server/src/server/service/diagram/paste_component.rs +++ b/lib/sdf-server/src/server/service/diagram/paste_component.rs @@ -144,7 +144,7 @@ pub async fn paste_components( &pasted_component, ChangeStatus::Added, )?; - WsEvent::connection_created(&ctx, edge) + WsEvent::connection_upserted(&ctx, edge) .await? .publish_on_commit(&ctx) .await?;