Skip to content

Commit

Permalink
fix(web): wait for all components to be loaded into the components.st…
Browse files Browse the repository at this point in the history
…ore before hydrating each view's geometry mapping lazily
  • Loading branch information
britmyerss committed Nov 27, 2024
1 parent fba53dc commit 7f7b098
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 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
24 changes: 13 additions & 11 deletions app/web/src/store/views.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,6 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
views,
});
this.selectView(response.view.id);

componentsStore.FETCH_ALL_COMPONENTS();
},
});
},
Expand Down Expand Up @@ -1266,13 +1264,13 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
const idAndType =
categoryVariant.type === "installed"
? {
schemaType: "installed",
schemaVariantId: categoryVariant.variant.schemaVariantId,
}
schemaType: "installed",
schemaVariantId: categoryVariant.variant.schemaVariantId,
}
: {
schemaType: "uninstalled",
schemaId: categoryVariant.variant.schemaId,
};
schemaType: "uninstalled",
schemaId: categoryVariant.variant.schemaId,
};

const tempInsertId = _.uniqueId("temp-insert-component");

Expand Down Expand Up @@ -1454,8 +1452,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 @@ -1501,6 +1501,7 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
if (route?.params.viewId) viewId = route.params.viewId as string;
await this.FETCH_VIEW(viewId);
// ^ selects the view
await componentsStore.FETCH_ALL_COMPONENTS();
}
this.LIST_VIEWS();

Expand All @@ -1523,7 +1524,7 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
if (
lastId &&
Object.values(this.selectedComponentIds).filter(Boolean).length ===
0
0
) {
this.setSelectedComponentId(lastId);
}
Expand Down Expand Up @@ -1846,6 +1847,7 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
// then refetch (i.e. there might be updates!)
if (data.toRebaseChangeSetId === changeSetId) {
this.FETCH_VIEW();
componentsStore.FETCH_ALL_COMPONENTS();
this.LIST_VIEWS();
// LOAD ALL OTHER VIEW DATA, if its dirty
}
Expand Down

0 comments on commit 7f7b098

Please sign in to comment.