Fix bug which causes an 'undefined' layout to appear if the save call 409s

This commit is contained in:
Andrew Kingston 2021-06-30 09:35:31 +01:00
parent 2693878a72
commit c936ab2619
1 changed files with 5 additions and 0 deletions

View File

@ -211,6 +211,11 @@ export const getFrontendStore = () => {
const response = await api.post(`/api/layouts`, layoutToSave) const response = await api.post(`/api/layouts`, layoutToSave)
const savedLayout = await response.json() const savedLayout = await response.json()
// Abort if saving failed
if (response.status !== 200) {
return
}
store.update(state => { store.update(state => {
const layoutIdx = state.layouts.findIndex( const layoutIdx = state.layouts.findIndex(
stateLayout => stateLayout._id === savedLayout._id stateLayout => stateLayout._id === savedLayout._id