Fix crash when having a screen selected that was deleted

This commit is contained in:
Andrew Kingston 2020-12-09 11:37:09 +00:00
parent 05b9c3fa68
commit 31b3fac659
1 changed files with 8 additions and 5 deletions

View File

@ -86,13 +86,16 @@ export const getFrontendStore = () => {
select: async screenId => {
let promise
store.update(state => {
const screen = get(allScreens).find(screen => screen._id === screenId)
const screens = get(allScreens)
let selectedScreen = screens.find(screen => screen._id === screenId)
if (!selectedScreen) {
selectedScreen = screens[0]
}
state.currentFrontEndType = FrontendTypes.SCREEN
state.currentAssetId = screenId
state.currentAssetId = selectedScreen._id
state.currentView = "detail"
promise = store.actions.screens.regenerateCss(screen)
state.selectedComponentId = screen.props._id
promise = store.actions.screens.regenerateCss(selectedScreen)
state.selectedComponentId = selectedScreen.props._id
return state
})
await promise