Skip to content

Commit

Permalink
fix lineage when history is an object rather then a string or empty l…
Browse files Browse the repository at this point in the history
…ist. this happens on some older records
  • Loading branch information
fostermh committed Jul 17, 2024
1 parent 4ba3f21 commit 8251add
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/components/FormComponents/Lineage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ const Lineage = ({
}, {});




function addLineage() {
updateLineage(history.concat(deepCopy(emptyLineage)));
setActiveLineage(history.length);
Expand Down Expand Up @@ -137,16 +135,24 @@ const Lineage = ({
if (!deepEquals(currentLineage, history)) {
setCurrentLineage(history);
}
const lineageStep = history.length > 0 && history[activeLineage];

if (lineageStep && !lineageStep.scope){
lineageStep.scope = metadataScope;
}

if (typeof history === 'string' || history instanceof String) {
// eslint-disable-next-line no-param-reassign
history = []

} else if (typeof history === 'object' && !Array.isArray(history)) {
const oldHistory = deepCopy(history)
// eslint-disable-next-line no-param-reassign
history = []
// eslint-disable-next-line no-param-reassign
history[0] = deepCopy(emptyLineage)
// eslint-disable-next-line no-param-reassign
history[0].statement = oldHistory;
}

const lineageStep = history.length > 0 && history[activeLineage];

if (lineageStep && !lineageStep.scope){
lineageStep.scope = metadataScope;
}

return (
Expand Down

0 comments on commit 8251add

Please sign in to comment.