Fix crash when having a screen selected that was deleted
This commit is contained in:
parent
2e68f51b8f
commit
68ed9e9f32
|
@ -86,13 +86,16 @@ export const getFrontendStore = () => {
|
||||||
select: async screenId => {
|
select: async screenId => {
|
||||||
let promise
|
let promise
|
||||||
store.update(state => {
|
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.currentFrontEndType = FrontendTypes.SCREEN
|
||||||
state.currentAssetId = screenId
|
state.currentAssetId = selectedScreen._id
|
||||||
state.currentView = "detail"
|
state.currentView = "detail"
|
||||||
|
promise = store.actions.screens.regenerateCss(selectedScreen)
|
||||||
promise = store.actions.screens.regenerateCss(screen)
|
state.selectedComponentId = selectedScreen.props._id
|
||||||
state.selectedComponentId = screen.props._id
|
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
await promise
|
await promise
|
||||||
|
|
Loading…
Reference in New Issue