1
0
Fork 0
mirror of synced 2024-09-29 08:41:16 +13:00

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 2e68f51b8f
commit 68ed9e9f32

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