Skip to content

Commit 9d001d7

Browse files
fix(proxy-state-tree): fix accessing proxy with wrong tree proxy
1 parent 7bf7870 commit 9d001d7

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

packages/node_modules/overmind-devtools/src/app/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ export const toggleCollapsedOperator: Action<number> = ({
132132
state,
133133
}) => {
134134
if (!state.expandAllActionDetails) {
135-
const operator = state.currentAction.operators[operatorIndex]
135+
const currentApp = state.apps[state.currentAppName]
136+
const currentAction = currentApp.actions[currentApp.currentActionId]
137+
const operator = currentAction.operators[operatorIndex]
138+
136139
operator.isCollapsed = !operator.isCollapsed
137140
}
138141
}

packages/node_modules/proxy-state-tree/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ describe('FUNCTIONS', () => {
498498
item.title
499499
})
500500
const paths = tree.clearPathsTracking(trackId)
501-
console.log(paths)
501+
502502
tree.addFlushListener(paths, (flushId) => {
503503
reactionCount++
504504
expect(flushId).toBe(0)

packages/node_modules/proxy-state-tree/src/proxify.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,20 @@ function createObjectProxy(tree, value, path) {
126126
trackPath(tree, nestedPath)
127127

128128
if (typeof targetValue === 'function') {
129-
return tree.options.dynamicWrapper
129+
const dynamicValue = tree.options.dynamicWrapper
130130
? tree.options.dynamicWrapper(tree, nestedPath, targetValue)
131131
: targetValue(tree, nestedPath)
132+
133+
if (dynamicValue[IS_PROXY]) {
134+
delete dynamicValue[VALUE][tree.PROXY]
135+
Object.defineProperty(dynamicValue[VALUE], tree.PROXY, {
136+
configurable: true,
137+
value: proxify(tree, dynamicValue[VALUE], dynamicValue[PATH]),
138+
})
139+
return dynamicValue[VALUE][tree.PROXY]
140+
}
141+
142+
return dynamicValue
132143
}
133144

134145
if (targetValue === undefined) {
@@ -186,6 +197,10 @@ function getValue(value, tree) {
186197
return value
187198
}
188199

200+
if (value[IS_PROXY]) {
201+
return value[VALUE][tree.PROXY] || value[VALUE]
202+
}
203+
189204
if (value[tree.PROXY]) {
190205
return value[tree.PROXY]
191206
}

0 commit comments

Comments
 (0)