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