Skip to content

Commit 3ab046c

Browse files
committed
2 parents 383a350 + 5ab6819 commit 3ab046c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export default function makeServiceMutations() {
151151
// If an item already exists in the store from the `created` event firing
152152
// it will be replaced here
153153
Vue.set(state.keyedById, id, temp)
154+
// Only add the id if it's not already in the `ids` list.
155+
if (!state.ids.includes(id)) {
156+
state.ids.push(id)
157+
}
154158
}
155159

156160
// Add _id to temp's clone as well if it exists

test/service-module/model-temp-ids.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ describe('Models - Temp Ids', function() {
431431
store.commit('things/updateTemp', { id: 42, tempId: thing.__id })
432432
assert(thing._id === 42, 'thing got _id')
433433
assert(store.state.things.keyedById[42] === thing, 'thing is in keyedById')
434+
assert(store.state.things.ids.includes(42), "thing's _id is in ids")
434435
assert(
435436
!store.state.things.tempsById[thing.__id],
436437
'thing is no longer in tempsById'

test/service-module/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ eslint
55
*/
66
export interface ServiceState {
77
options: {}
8-
ids: string[]
8+
ids: (string | number)[]
99
autoRemove: boolean
1010
errorOnFind: any
1111
errorOnGet: any

0 commit comments

Comments
 (0)