Skip to content
Snippets Groups Projects
Commit f1c8267c authored by Jure's avatar Jure
Browse files

Merge branch 'fragment-actions' into 'master'

Fix top level fragment actions

See merge request pubsweet/pubsweet!31
parents ce2acbce 128df4f4
No related branches found
No related tags found
No related merge requests found
......@@ -69,26 +69,30 @@ export default function(state = [], action) {
}
function addFragments() {
const collection = getCollection()
if (collection) {
collection.fragments = union(
collection.fragments,
(action.fragments || [action.fragment]).map(fragment => fragment.id),
)
if (action.collection) {
const collection = getCollection()
if (collection) {
collection.fragments = union(
collection.fragments,
(action.fragments || [action.fragment]).map(fragment => fragment.id),
)
}
}
return collections
}
function removeFragments() {
const collection = getCollection()
if (collection) {
collection.fragments = difference(
collection.fragments,
(action.fragments || [action.fragment]).map(fragment => fragment.id),
)
if (action.collection) {
const collection = getCollection()
if (collection) {
collection.fragments = difference(
collection.fragments,
(action.fragments || [action.fragment]).map(fragment => fragment.id),
)
}
}
return collections
......
......@@ -21,7 +21,9 @@ export default function(state = {}, action) {
const fragments = clone(state)
function replaceAll() {
unset(fragments, action.collection.fragments)
if (action.collection) {
unset(fragments, action.collection.fragments)
}
action.fragments.forEach(fragment => {
fragments[fragment.id] = fragment
})
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment