Skip to content

Commit 5f88a8b

Browse files
fix(overmind-devtools): properly handle mutations delimiter
1 parent d80ed09 commit 5f88a8b

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

packages/node_modules/overmind-devtools-client/src/components/ActionOperator/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const ActionOperator: FunctionComponent<Props> = ({
131131
textStyles.monospace
132132
)}
133133
>
134-
{mutation.path}
134+
{mutation.path.replace(new RegExp(delimiter, 'g'), '.')}
135135
</span>
136136
{mutation.args.map((arg, argIndex) => (
137137
<ValueInspector delimiter={delimiter} key={argIndex} small value={arg} />

packages/node_modules/overmind-devtools-client/src/components/Inspector/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const Nested: FunctionComponent<NestedProps> = memo(
234234
className={styles.bracket(true)}
235235
onClick={(event) => {
236236
event.stopPropagation()
237-
onToggleExpand(path.split('.'))
237+
onToggleExpand(path.split(delimiter))
238238
}}
239239
>
240240
<PathKey

packages/node_modules/overmind-devtools-client/src/overmind/operators.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ export const updateDerived: () => Operator<DerivedMessage> = () =>
161161
target[key] = message.data.value
162162

163163
state.apps[message.appName].derived[message.data.path.join('.')] = message.data
164-
165-
console.log(state.apps[message.appName].derived)
166164
})
167165

168166
export const updateFlushWithDerived: () => Operator<DirtyDerivedMessage> = () =>

packages/node_modules/overmind-devtools-client/src/overmind/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as ColorHash from 'color-hash'
33
import { Action, App, Flush, OperatorsByPath } from './types'
44

55
export const runMutation = (state) => (mutation) => {
6-
const pathArray = mutation.path.split('.')
6+
const pathArray = mutation.path.split(mutation.delimiter)
77
const key = pathArray.pop()
8-
const target = pathArray.reduce((current, pathKey) => current[pathKey].__CLASS__ ? current[pathKey].value : current[pathKey], state)
8+
const target = pathArray.reduce((current, pathKey) => current[pathKey].__CLASS__ ? current[pathKey].value : current[pathKey], state)
99

1010
switch (mutation.method) {
1111
case 'set':
@@ -35,6 +35,7 @@ export const createApp = (data: Partial<App>): App =>
3535
{
3636
name: null,
3737
messages: [],
38+
delimiter: '.',
3839
state: {},
3940
components: {},
4041
derived: {},

packages/node_modules/overmind/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,9 @@ export class Overmind<ThisConfig extends IConfiguration>
827827
})
828828
}
829829

830-
// Access the derived async, which will trigger calculation and devtools
830+
// Access the derived which will trigger calculation and devtools
831831
if (eventType === EventType.DERIVED_DIRTY) {
832832
data.derivedPath
833-
.split(this.delimiter)
834833
.reduce((aggr, key) => aggr[key], this.proxyStateTree.state)
835834
}
836835
})(EventType[type])

0 commit comments

Comments
 (0)