Remove debug logs and add comments

This commit is contained in:
Andrew Kingston 2022-07-15 09:14:54 +01:00
parent aa1c0298bc
commit b4420fb74a
1 changed files with 6 additions and 4 deletions

View File

@ -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 })