Reload app metadata when adding custom components
This commit is contained in:
parent
846b58364f
commit
4e916d2812
|
@ -227,9 +227,18 @@ export const getFrontendStore = () => {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
save: async screen => {
|
save: async screen => {
|
||||||
|
const state = get(store)
|
||||||
const creatingNewScreen = screen._id === undefined
|
const creatingNewScreen = screen._id === undefined
|
||||||
const savedScreen = await API.saveScreen(screen)
|
const savedScreen = await API.saveScreen(screen)
|
||||||
const routesResponse = await API.fetchAppRoutes()
|
const routesResponse = await API.fetchAppRoutes()
|
||||||
|
let usedPlugins = state.usedPlugins
|
||||||
|
|
||||||
|
// If plugins changed we need to fetch the latest app metadata
|
||||||
|
if (savedScreen.pluginAdded) {
|
||||||
|
const { application } = await API.fetchAppPackage(state.appId)
|
||||||
|
usedPlugins = application.usedPlugins || []
|
||||||
|
}
|
||||||
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
// Update screen object
|
// Update screen object
|
||||||
const idx = state.screens.findIndex(x => x._id === savedScreen._id)
|
const idx = state.screens.findIndex(x => x._id === savedScreen._id)
|
||||||
|
@ -248,6 +257,9 @@ export const getFrontendStore = () => {
|
||||||
// Update routes
|
// Update routes
|
||||||
state.routes = routesResponse.routes
|
state.routes = routesResponse.routes
|
||||||
|
|
||||||
|
// Update used plugins
|
||||||
|
state.usedPlugins = usedPlugins
|
||||||
|
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
return savedScreen
|
return savedScreen
|
||||||
|
|
Loading…
Reference in New Issue