Skip to content

Commit

Permalink
Merge pull request #5034 from systeminit/brit/bug-688-when-a-componen…
Browse files Browse the repository at this point in the history
…ts-parent-is-in-the-same-view-it-should

fix(web): wait for all components to be loaded into the components.store before hydrating each view's geometry mapping lazily
  • Loading branch information
vbustamante authored Nov 27, 2024
2 parents ff00fcf + f0b7743 commit a1b41f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/web/src/components/LeftPanelDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ const create = async () => {
} else {
const resp = await viewStore.CREATE_VIEW(viewName.value);
if (resp.result.success) {
viewStore.selectView(resp.result.data.id);
modalRef.value?.close();
viewStore.selectView(resp.result.data.id);
viewName.value = "";
} else if (resp.result.statusCode === 409) {
labelRef.value?.setError(
Expand Down
17 changes: 13 additions & 4 deletions app/web/src/store/views.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
this.recentViews.push(id);
},
async LIST_VIEWS() {
await componentsStore.FETCH_ALL_COMPONENTS();

return new ApiRequest<ViewDescription[]>({
method: "get",
url: API_PREFIX,
Expand Down Expand Up @@ -803,8 +805,6 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
views,
});
this.selectView(response.view.id);

componentsStore.FETCH_ALL_COMPONENTS();
},
});
},
Expand Down Expand Up @@ -1441,8 +1441,10 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
...visibilityParams,
},
onFail: (err) => {
if (err.response.status === 403) {
toast("Error: This component already exists in this view");
if (err.response.status === 422) {
toast(
"Error: One or more of the selected components already exists in this view",
);
}
},
});
Expand Down Expand Up @@ -1810,6 +1812,13 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
if (!c) return;
if (c.def.isGroup) view.groups[componentId] = geo;
else view.components[componentId] = geo;
if (geo) {
for (const [key, loc] of Object.entries(
setSockets(c, geo),
)) {
view.sockets[key] = loc;
}
}
});
removed.forEach((r) => {
delete view.components[r];
Expand Down

0 comments on commit a1b41f9

Please sign in to comment.