Update client library to work with template screens in real preview

This commit is contained in:
Andrew Kingston 2020-12-04 14:04:07 +00:00
parent 75e4b4f8cd
commit 155c375ada
1 changed files with 15 additions and 14 deletions

View File

@ -20,20 +20,21 @@ const createScreenStore = () => {
activeScreen = $builderStore.screen
} else {
// Otherwise find the correct screen by matching the current route
// const { screens, layouts } = $config
// activeLayout = layouts[0]
// if (screens.length === 1) {
// activeScreen = screens[0]
// } else {
// activeScreen = screens.find(
// screen => screen.routing.route === $routeStore.activeRoute
// )
// }
// if (activeScreen) {
// activeLayout = layouts.find(
// layout => layout._id === activeScreen.props.layoutId
// )
// }
const { screens, layouts } = $config
console.log(screens)
activeLayout = layouts[0]
if (screens.length === 1) {
activeScreen = screens[0]
} else {
activeScreen = screens.find(
screen => screen.routing.route === $routeStore.activeRoute
)
}
if (activeScreen) {
activeLayout = layouts.find(
layout => layout._id === activeScreen.props.layoutId
)
}
}
return { activeLayout, activeScreen }
}