Skip to content

Commit

Permalink
skip calling getRemixValidPathsGenerationContext if not in remixScene
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsbajorics committed Jul 12, 2024
1 parent 861e4eb commit 17ca236
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions editor/src/components/canvas/canvas-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,55 +1774,57 @@ function getValidElementPathsFromElement(
let paths = includeElementInPath ? [path] : []
if (isJSXElementLike(element)) {
const isRemixScene = isRemixSceneElement(element, filePath, projectContents)
const remixPathGenerationContext = getRemixValidPathsGenerationContext(path)
if (remixPathGenerationContext.type === 'active' && isRemixScene) {
function makeValidPathsFromModule(routeModulePath: string, parentPathInner: ElementPath) {
const file = getProjectFileByFilePath(projectContents, routeModulePath)
if (file == null || file.type !== 'TEXT_FILE') {
return
}
if (isRemixScene) {
const remixPathGenerationContext = getRemixValidPathsGenerationContext(path)
if (remixPathGenerationContext.type === 'active') {
function makeValidPathsFromModule(routeModulePath: string, parentPathInner: ElementPath) {
const file = getProjectFileByFilePath(projectContents, routeModulePath)
if (file == null || file.type !== 'TEXT_FILE') {
return
}

const topLevelElement = getDefaultExportedTopLevelElement(file)
const topLevelElement = getDefaultExportedTopLevelElement(file)

if (topLevelElement == null) {
return
}
if (topLevelElement == null) {
return
}

paths.push(
...getValidElementPathsFromElement(
focusedElementPath,
topLevelElement,
parentPathInner,
projectContents,
autoFocusedPaths,
routeModulePath,
uiFilePath,
false,
true,
true,
resolve,
getRemixValidPathsGenerationContext,
),
)
}
paths.push(
...getValidElementPathsFromElement(
focusedElementPath,
topLevelElement,
parentPathInner,
projectContents,
autoFocusedPaths,
routeModulePath,
uiFilePath,
false,
true,
true,
resolve,
getRemixValidPathsGenerationContext,
),
)
}

/**
* The null check is here to guard against the case when a route with children is missing an outlet
* that would render the children
*/

for (const route of remixPathGenerationContext.currentlyRenderedRouteModules) {
const entry = remixPathGenerationContext.routeModulesToRelativePaths[route.id]
if (entry != null) {
const { relativePaths, filePath: filePathOfRouteModule } = entry
for (const relativePath of relativePaths) {
const basePath = EP.appendTwoPaths(path, relativePath)
makeValidPathsFromModule(filePathOfRouteModule, basePath)
/**
* The null check is here to guard against the case when a route with children is missing an outlet
* that would render the children
*/

for (const route of remixPathGenerationContext.currentlyRenderedRouteModules) {
const entry = remixPathGenerationContext.routeModulesToRelativePaths[route.id]
if (entry != null) {
const { relativePaths, filePath: filePathOfRouteModule } = entry
for (const relativePath of relativePaths) {
const basePath = EP.appendTwoPaths(path, relativePath)
makeValidPathsFromModule(filePathOfRouteModule, basePath)
}
}
}
}

return paths
return paths
}
}

const isScene = isSceneElement(element, filePath, projectContents)
Expand Down

0 comments on commit 17ca236

Please sign in to comment.