Skip to content

Commit

Permalink
fix: hostless packages not cached
Browse files Browse the repository at this point in the history
Change-Id: Ia6ef9b673de8e7ee042767433467b5547cae197f
GitOrigin-RevId: a8410f6e192a6fa881a6665cc1d125c99b1357f1
  • Loading branch information
jaslong authored and actions-user committed Dec 13, 2024
1 parent f485fe2 commit ba3b869
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,6 @@ const Row = React.memo(function Row(props: {
},
areEqual);

type HostLessStuff = ReturnType<typeof getHostLess>;
let cachedHostLess: HostLessStuff | undefined = undefined;

const getTemplateComponents = memoizeOne(function getTemplateComponent(
studioCtx: StudioCtx
) {
Expand All @@ -853,7 +850,7 @@ const getTemplateComponents = memoizeOne(function getTemplateComponent(
);
});

function getHostLess(studioCtx: StudioCtx): AddItemGroup[] {
const getHostLess = memoizeOne((studioCtx: StudioCtx): AddItemGroup[] => {
const hostLessComponentsMeta =
studioCtx.appCtx.appConfig.hostLessComponents ??
DEVFLAGS.hostLessComponents ??
Expand Down Expand Up @@ -913,14 +910,7 @@ function getHostLess(studioCtx: StudioCtx): AddItemGroup[] {
};
return newVar;
});
}

function initHostLess(studioCtx: StudioCtx) {
if (!cachedHostLess) {
cachedHostLess = getHostLess(studioCtx);
}
return cachedHostLess;
}
});

/**
* For hostless components and default components. Otherwise it's a built-in insertable.
Expand Down Expand Up @@ -1170,7 +1160,7 @@ export function buildAddItemGroups({
}

// Is this a hostless component entry?
for (const hostlessGroup of initHostLess(studioCtx) ?? []) {
for (const hostlessGroup of getHostLess(studioCtx)) {
if (
canInsertHostlessPackage(
uiConfig,
Expand Down Expand Up @@ -1385,9 +1375,9 @@ export function buildAddItemGroups({
],
})),

...(!!hostLessComponentsMeta && cachedHostLess
? // We want to hide the listings that were shown in "Default components" - this is just a simple way to ensure things don't show up in both menus.
cachedHostLess
// We want to hide the listings that were shown in "Default components" - this is just a simple way to ensure things don't show up in both menus.
...(!!hostLessComponentsMeta
? getHostLess(studioCtx)
.filter((group) =>
canInsertHostlessPackage(
uiConfig,
Expand Down

0 comments on commit ba3b869

Please sign in to comment.