Skip to content

Commit

Permalink
Merge pull request #5165 from systeminit/fix/all-components-call-in-a…
Browse files Browse the repository at this point in the history
…-good-place

Fix: load all components at the right time
  • Loading branch information
jobelenus authored Dec 20, 2024
2 parents 81f2c70 + b6aeeb7 commit b2b411c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
18 changes: 0 additions & 18 deletions app/web/src/store/components.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1427,29 +1427,11 @@ export const useComponentsStore = (forceChangeSetId?: ChangeSetId) => {
],
);

realtimeStore.subscribe(
`${this.$id}-workspace`,
`workspace/${workspaceId}`,
[
{
eventType: "ChangeSetApplied",
callback: (data) => {
// If the applied change set has rebased into this change set,
// then refetch (i.e. there might be updates!)
if (data.toRebaseChangeSetId === changeSetId) {
this.FETCH_ALL_COMPONENTS();
}
},
},
],
);

const actionUnsub = this.$onAction(handleStoreError);

return () => {
actionUnsub();
realtimeStore.unsubscribe(`${this.$id}-changeset`);
realtimeStore.unsubscribe(`${this.$id}-workspace`);
};
},
},
Expand Down
5 changes: 2 additions & 3 deletions app/web/src/store/views.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,13 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
this.recentViews.push(id);
},
async LIST_VIEWS(all = false) {
await componentsStore.FETCH_ALL_COMPONENTS();

return new ApiRequest<ViewDescription[]>({
method: "get",
url: API_PREFIX,
onSuccess: async (views) => {
this.viewList = views;
this.SORT_LIST_VIEWS();
await componentsStore.FETCH_ALL_COMPONENTS();
for (const { id } of views) {
// assuming we're coming from "on load", we have the FETCH that gets the selectedViewId
if (all || id !== this.selectedViewId)
Expand All @@ -674,6 +673,7 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
});
},
async FETCH_VIEW_GEOMETRY(viewId: ViewId) {
// requires all components to be in place!
return new ApiRequest<{
viewId: ViewId;
name: string;
Expand Down Expand Up @@ -709,7 +709,6 @@ export const useViewsStore = (forceChangeSetId?: ChangeSetId) => {
([componentId, geo]) => {
const node = componentsStore.allComponentsById[componentId];
if (!node) return;
if (!view) return; // no idea why linting is complaining that i need this
let geometry: IRect;
if ("width" in node) {
geo.width = node.width;
Expand Down

0 comments on commit b2b411c

Please sign in to comment.