From b82c57fac8b2b372dd7644fd7edba80c480f2b06 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 15 Jul 2022 09:14:54 +0100 Subject: [PATCH] Remove debug logs and add comments --- packages/builder/src/builderStore/store/frontend.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 0a12d348bc..df4abdbee5 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -61,6 +61,12 @@ const INITIAL_FRONTEND_STATE = { export const getFrontendStore = () => { const store = writable({ ...INITIAL_FRONTEND_STATE }) + // This is a fake implementation of a "patch" API endpoint to try and prevent + // 409s. All screen doc mutations (aside from creation) use this function, + // which queues up invocations sequentially and ensures pending mutations are + // always applied to the most up-to-date doc revision. + // This is slightly better than just a traditional "patch" endpoint and this + // supports deeply mutating the current doc rather than just appending data. const sequentialScreenPatch = Utils.sequential(async (patchFn, screenId) => { const state = get(store) const screen = state.screens.find(screen => screen._id === screenId) @@ -75,10 +81,6 @@ export const getFrontendStore = () => { return await store.actions.screens.save(clone) }) - store.subscribe(() => { - console.log("new state") - }) - store.actions = { reset: () => { store.set({ ...INITIAL_FRONTEND_STATE })