From fa2fcb0632c40b14b8a2831c5f5c530e0de3c96d Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Tue, 2 Jun 2020 11:19:22 +0100 Subject: [PATCH] Lint and testing --- .../builder/src/builderStore/store/index.js | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 9ac06a0a0d..9762ca4e27 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -1,4 +1,3 @@ - import { values } from "lodash/fp" import { backendUiStore } from "builderStore" import * as backendStoreActions from "./backend" @@ -120,28 +119,33 @@ const saveScreen = store => screen => { } const _saveScreen = async (store, s, screen) => { - const currentPageScreens = s.pages[s.currentPageName]._screens; + const currentPageScreens = s.pages[s.currentPageName]._screens - await api.post(`/_builder/api/${s.appId}/pages/${s.currentPageName}/screen`, screen).then(() => { - if (currentPageScreens.includes(screen)) return; + await api + .post(`/_builder/api/${s.appId}/pages/${s.currentPageName}/screen`, screen) + .then(() => { + if (currentPageScreens.includes(screen)) return - const screens = [ ...currentPageScreens, screen ]; + const screens = [...currentPageScreens, screen] - store.update((innerState) => { - innerState.pages[s.currentPageName]._screens = screens; - innerState.screens = screens; - innerState.currentPreviewItem = screen; - const safeProps = makePropsSafe(innerState.components[screen.props._component], screen.props); - innerState.currentComponentInfo = safeProps; - screen.props = safeProps; + store.update(innerState => { + innerState.pages[s.currentPageName]._screens = screens + innerState.screens = screens + innerState.currentPreviewItem = screen + const safeProps = makePropsSafe( + innerState.components[screen.props._component], + screen.props + ) + innerState.currentComponentInfo = safeProps + screen.props = safeProps - _savePage(innerState); - return innerState; - }); - }); + _savePage(innerState) + return innerState + }) + }) - return s; -}; + return s +} const createScreen = store => (screenName, route, layoutComponentName) => { store.update(state => {