Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: BUG-735 consolidate these two events into one place and add the geo assignment #5227

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions app/web/src/store/components.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,21 +1384,6 @@ export const useComponentsStore = (forceChangeSetId?: ChangeSetId) => {
}
},
},
{
eventType: "ComponentUpgraded",
callback: (data) => {
// If the component that updated wasn't in this change set,
// don't update
if (data.changeSetId !== changeSetId) return;
// the componentIds ought to be the same, but just in case we'll delete first
delete this.rawComponentsById[data.originalComponentId];
delete this.allComponentsById[data.originalComponentId];
delete this.nodesById[data.originalComponentId];
delete this.groupsById[data.originalComponentId];
this.rawComponentsById[data.component.id] = data.component;
this.processAndStoreRawComponent(data.component.id, {});
},
},
{
eventType: "ResourceRefreshed",
callback: (data) => {
Expand Down
31 changes: 26 additions & 5 deletions app/web/src/store/views.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1687,11 +1687,22 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
// don't update
if (data.changeSetId !== changeSetId) return;

this.setSelectedComponentId(data.component.id);
const node = processRawComponent(
data.component,
componentsStore.rawComponentsById,
);
const oldId = data.originalComponentId;
delete componentsStore.rawComponentsById[oldId];
delete componentsStore.allComponentsById[oldId];
delete componentsStore.nodesById[oldId];
delete componentsStore.groupsById[oldId];
componentsStore.rawComponentsById[data.component.id] =
data.component;
componentsStore.processAndStoreRawComponent(
data.component.id,
{},
); // now the component exists in the component store

const node =
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
componentsStore.allComponentsById[data.component.id]!;

// upgrades can change the sockets on a component
// so we need to go through all the views this component is on
// and re-set their socket data
Expand All @@ -1702,13 +1713,23 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
let geo = view.components[data.component.id];
if (!geo) geo = view.groups[data.component.id];
if (geo) {
if ("height" in node) {
// this covers components
geo.height = node.height;
geo.width = node.width;
// note: if a person added a hundred sockets to a component
// and that component was a frame, it would not resize itself
// and the sockets would appear outside the frame
}
for (const [key, loc] of Object.entries(
setSockets(node, geo),
)) {
view.sockets[key] = loc;
}
}
});

this.setSelectedComponentId(data.component.id);
},
},
{
Expand Down
Loading