Skip to content

Commit 917af6e

Browse files
committed
refactor: _get as in #544
1 parent fab53b2 commit 917af6e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/service-module/service-module.getters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const getCopiesById = ({
2525
if (keepCopiesInStore) {
2626
return copiesById
2727
} else {
28-
const Model = _get(models, `[${serverAlias}].byServicePath[${servicePath}]`)
28+
const Model = _get(models, [serverAlias, 'byServicePath', servicePath])
2929

3030
return Model.copiesById
3131
}

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ export default function makeServiceMutations() {
235235
return map
236236
}, {})
237237

238-
const Model = _get(models, `[${state.serverAlias}][${state.modelName}]`)
238+
const Model = _get(models, [
239+
state.serverAlias,
240+
'byServicePath',
241+
state.servicePath
242+
])
239243
const copiesById = state.keepCopiesInStore
240244
? state.copiesById
241245
: Model.copiesById
@@ -278,10 +282,11 @@ export default function makeServiceMutations() {
278282
if (state.keepCopiesInStore) {
279283
state.copiesById = {}
280284
} else {
281-
const Model = _get(
282-
models,
283-
`[${state.serverAlias}].byServicePath[${state.servicePath}]`
284-
)
285+
const Model = _get(models, [
286+
state.serverAlias,
287+
'byServicePath',
288+
state.servicePath
289+
])
285290
Object.keys(Model.copiesById).forEach(k =>
286291
Vue.delete(Model.copiesById, k)
287292
)
@@ -365,10 +370,11 @@ export default function makeServiceMutations() {
365370
// Removes the copy from copiesById
366371
clearCopy(state, id) {
367372
const { keepCopiesInStore } = state
368-
const Model = _get(
369-
models,
370-
`[${state.serverAlias}].byServicePath[${state.servicePath}]`
371-
)
373+
const Model = _get(models, [
374+
state.serverAlias,
375+
'byServicePath',
376+
state.servicePath
377+
])
372378

373379
const copiesById = keepCopiesInStore ? state.copiesById : Model.copiesById
374380

0 commit comments

Comments
 (0)