From da41c6d96adcc1cd220f527ace0edf91e0cbf6c8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 14 Jul 2022 16:21:37 +0100 Subject: [PATCH] Use patch when detaching screen custom layouts --- .../builder/src/builderStore/store/frontend.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index a2d7fa78ed..6d836dad65 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -294,25 +294,27 @@ export const getFrontendStore = () => { ) }) if (existingHomeScreen) { - const patchFn = screen => (screen.routing.homeScreen = false) + const patch = screen => (screen.routing.homeScreen = false) promises.push( - store.actions.screens.patch(existingHomeScreen._id, patchFn) + store.actions.screens.patch(existingHomeScreen._id, patch) ) } } // Update the passed in screen - const patchFn = screen => (screen.routing.homeScreen = makeHomeScreen) - promises.push(store.actions.screens.patch(screen._id, patchFn)) + const patch = screen => (screen.routing.homeScreen = makeHomeScreen) + promises.push(store.actions.screens.patch(screen._id, patch)) return await Promise.all(promises) }, removeCustomLayout: async screen => { // Pull relevant settings from old layout, if required const layout = get(store).layouts.find(x => x._id === screen.layoutId) - screen.layoutId = null - screen.showNavigation = layout?.props.navigation !== "None" - screen.width = layout?.props.width || "Large" - await store.actions.screens.save(screen) + const patch = screen => { + screen.layoutId = null + screen.showNavigation = layout?.props.navigation !== "None" + screen.width = layout?.props.width || "Large" + } + await store.actions.screens.patch(screen._id, patch) }, }, preview: {