1
0
Fork 0
mirror of synced 2024-09-14 00:08:25 +12:00

Reload app metadata when adding custom components

This commit is contained in:
Andrew Kingston 2022-08-11 17:05:04 +01:00
parent 846b58364f
commit 4e916d2812

View file

@ -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