Makes the reducer a bit more debuggable
This commit is contained in:
@@ -137,6 +137,7 @@ export function reducer(
|
||||
state: DocumentState,
|
||||
action: DocumentAction,
|
||||
): DocumentState {
|
||||
console.debug("Processing action", action);
|
||||
switch (action.type) {
|
||||
case "loadingDocument":
|
||||
return setLoadingDocument(action.docId, state);
|
||||
@@ -145,15 +146,17 @@ export function reducer(
|
||||
case "setRelationship":
|
||||
return setRelationship(action.docId, state, action.relationship);
|
||||
case "setDocumentTree":
|
||||
return action.relatedDocuments.reduce(
|
||||
setDocument,
|
||||
action.relationships.reduce(
|
||||
setRelationship.bind(null, action.doc.id),
|
||||
setAllRelationshipsEmpty(
|
||||
const updatedDocumentState = setAllRelationshipsEmpty(
|
||||
action.doc.id,
|
||||
setDocument(state, action.doc),
|
||||
),
|
||||
),
|
||||
);
|
||||
const updatedRelationshipsState = action.relationships.reduce(
|
||||
setRelationship.bind(null, action.doc.id),
|
||||
updatedDocumentState,
|
||||
);
|
||||
return action.relatedDocuments.reduce(
|
||||
setDocument,
|
||||
updatedRelationshipsState,
|
||||
);
|
||||
case "removeDocument":
|
||||
return removeDocument(action.docId, state);
|
||||
|
||||
Reference in New Issue
Block a user