fix(store/reducer/object): handle type change

Fixes #1967
This commit is contained in:
Julien Fontanet
2017-02-28 16:14:07 +01:00
parent 9f64af859e
commit 5cf7f1f886

View File

@@ -102,16 +102,20 @@ export default {
for (const id in updates) {
const object = updates[id]
const previous = all[id]
if (object) {
const { type } = object.type
all[id] = object
get(object.type)[id] = object
} else {
const previous = all[id]
if (previous) {
delete all[id]
get(type)[id] = object
if (previous && previous.type !== type) {
delete get(previous.type)[id]
}
} else if (previous) {
delete all[id]
delete get(previous.type)[id]
}
}