Skip to content

Commit

Permalink
Renamed connection_created to connection_upserted, following Inferred…
Browse files Browse the repository at this point in the history
…Edge pattern. We can use this to send to_delete & ChangeStatus over the wire
  • Loading branch information
jobelenus committed Aug 14, 2024
1 parent 60d41bc commit 5f8efde
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/web/src/store/components.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/web/src/store/realtime/realtime_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export type WsEventPayloadMap = {
changeSetId: string;
edges: RawEdge[];
};
ConnectionCreated: RawEdge;
ConnectionUpserted: RawEdge;
ConnectionDeleted: {
fromComponentId: string;
toComponentId: string;
Expand Down
19 changes: 4 additions & 15 deletions lib/dal/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down Expand Up @@ -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?;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -4306,11 +4295,11 @@ impl WsEvent {
.await
}

pub async fn connection_created(
pub async fn connection_upserted(
ctx: &DalContext,
edge: SummaryDiagramEdge,
) -> WsEventResult<Self> {
WsEvent::new(ctx, WsPayload::ConnectionCreated(edge)).await
WsEvent::new(ctx, WsPayload::ConnectionUpserted(edge)).await
}

pub async fn connection_deleted(
Expand Down
2 changes: 1 addition & 1 deletion lib/dal/src/ws_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down

0 comments on commit 5f8efde

Please sign in to comment.