Skip to content

Commit

Permalink
zero in strategy dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrmendy committed Oct 25, 2024
1 parent b68bff6 commit 629c2cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import { reparentSubjectsForInteractionTarget } from './strategies/reparent-help
import { getReparentTargetUnified } from './strategies/reparent-helpers/reparent-strategy-parent-lookup'
import { gridRearrangeResizeKeyboardStrategy } from './strategies/grid-rearrange-keyboard-strategy'
import createCachedSelector from 're-reselect'
import { getActivePlugin } from '../plugins/style-plugins'
import { getActivePlugin, patchRemovedProperties } from '../plugins/style-plugins'
import {
controlsForGridPlaceholders,
GridControls,
Expand Down Expand Up @@ -495,6 +495,16 @@ export function applyCanvasStrategy(
return strategy.apply(strategyLifecycle)
}

export function applyElementsToRerenderFromStrategyResultAndZeroProps(
editorState: EditorState,
strategyResult: StrategyApplicationResult,
): EditorState {
return applyElementsToRerenderFromStrategyResult(
patchRemovedProperties(editorState),
strategyResult,
)
}

export function applyElementsToRerenderFromStrategyResult(
editorState: EditorState,
strategyResult: StrategyApplicationResult,
Expand Down
11 changes: 6 additions & 5 deletions editor/src/components/editor/store/dispatch-strategies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
import {
applyCanvasStrategy,
applyElementsToRerenderFromStrategyResult,
applyElementsToRerenderFromStrategyResultAndZeroProps,
findCanvasStrategy,
interactionInProgress,
pickCanvasStateFromEditorState,
Expand Down Expand Up @@ -222,7 +223,7 @@ export function interactionHardReset(

return {
unpatchedEditorState: newEditorState,
patchedEditorState: applyElementsToRerenderFromStrategyResult(
patchedEditorState: applyElementsToRerenderFromStrategyResultAndZeroProps(
commandResult.editorState,
strategyResult,
),
Expand Down Expand Up @@ -390,7 +391,7 @@ export function interactionStart(

return {
unpatchedEditorState: newEditorState,
patchedEditorState: applyElementsToRerenderFromStrategyResult(
patchedEditorState: applyElementsToRerenderFromStrategyResultAndZeroProps(
commandResult.editorState,
strategyResult,
),
Expand Down Expand Up @@ -497,7 +498,7 @@ function handleUserChangedStrategy(

return {
unpatchedEditorState: newEditorState,
patchedEditorState: applyElementsToRerenderFromStrategyResult(
patchedEditorState: applyElementsToRerenderFromStrategyResultAndZeroProps(
commandResult.editorState,
strategyResult,
),
Expand Down Expand Up @@ -583,7 +584,7 @@ function handleAccumulatingKeypresses(

return {
unpatchedEditorState: updatedEditorState,
patchedEditorState: applyElementsToRerenderFromStrategyResult(
patchedEditorState: applyElementsToRerenderFromStrategyResultAndZeroProps(
commandResult.editorState,
strategyResult,
),
Expand Down Expand Up @@ -650,7 +651,7 @@ function handleUpdate(
}
return {
unpatchedEditorState: newEditorState,
patchedEditorState: applyElementsToRerenderFromStrategyResult(
patchedEditorState: applyElementsToRerenderFromStrategyResultAndZeroProps(
commandResult.editorState,
strategyResult,
),
Expand Down
9 changes: 2 additions & 7 deletions editor/src/components/editor/store/dispatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1013,14 +1013,9 @@ function editorDispatchInner(
storedState.patchedDerived,
)

const unpatchedEditor = patchRemovedProperties(unpatchedEditorStateFromStrategies)
const patchedEditor = patchRemovedProperties(patchedEditorStateFromStrategies)

resetUpdatedPropertiesGlobal()

return {
unpatchedEditor: unpatchedEditor,
patchedEditor: patchedEditor,
unpatchedEditor: unpatchedEditorStateFromStrategies,
patchedEditor: patchedEditorStateFromStrategies,
unpatchedDerived: frozenDerivedState,
patchedDerived: patchedDerivedState,
strategyState: newStrategyState,
Expand Down

0 comments on commit 629c2cb

Please sign in to comment.