diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js
index c372f27bb7..f522c7bba1 100644
--- a/packages/builder/src/builderStore/store/automation/index.js
+++ b/packages/builder/src/builderStore/store/automation/index.js
@@ -46,21 +46,24 @@ const automationActions = store => ({
return state
})
},
- save: async ({ automation }) => {
+ save: async automation => {
const UPDATE_AUTOMATION_URL = `/api/automations`
const response = await api.put(UPDATE_AUTOMATION_URL, automation)
const json = await response.json()
store.update(state => {
+ const newAutomation = json.automation
const existingIdx = state.automations.findIndex(
existing => existing._id === automation._id
)
- state.automations.splice(existingIdx, 1, json.automation)
- state.automations = state.automations
- store.actions.select(json.automation)
- return state
+ if (existingIdx !== -1) {
+ state.automations.splice(existingIdx, 1, newAutomation)
+ state.automations = [...state.automations]
+ store.actions.select(newAutomation)
+ return state
+ }
})
},
- delete: async ({ automation }) => {
+ delete: async automation => {
const { _id, _rev } = automation
const DELETE_AUTOMATION_URL = `/api/automations/${_id}/${_rev}`
await api.delete(DELETE_AUTOMATION_URL)
@@ -70,7 +73,7 @@ const automationActions = store => ({
existing => existing._id === _id
)
state.automations.splice(existingIdx, 1)
- state.automations = state.automations
+ state.automations = [...state.automations]
state.selectedAutomation = null
state.selectedBlock = null
return state
diff --git a/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte b/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte
index a99c11e9e1..fc12b60676 100644
--- a/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte
+++ b/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte
@@ -1,20 +1,17 @@
+
+
+
+
+
+
+ Learn about automations
+
+
+
+
+