Skip to content

Commit 59bd17a

Browse files
committed
fix: clone while existing clone
- fix for keepCopiesInStore: true -> merge with existingClone like Model.clone behaviour
1 parent 3119f41 commit 59bd17a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/service-module/service-module.mutations.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,18 @@ export default function makeServiceMutations() {
253253
`[${serverAlias}].byServicePath[${servicePath}]`
254254
)
255255

256+
let item
257+
256258
if (Model) {
257-
var model = new Model(current, { clone: true })
259+
item = new Model(current, { clone: true })
258260
} else {
259-
var copyData = mergeWithAccessors({}, current)
261+
const existingClone = state.copiesById[id]
262+
263+
item = existingClone
264+
? mergeWithAccessors(existingClone, current)
265+
: mergeWithAccessors({}, current)
260266
}
261267

262-
let item = model || copyData
263268
if (keepCopiesInStore) {
264269
state.copiesById[id] = item
265270
} else {

0 commit comments

Comments
 (0)