Commit 42a69ae7 authored by Magnus Westergaard's avatar Magnus Westergaard
Browse files

DEICH-5555: If previewing a recommendation draft, hide all other recommendations.

parent fda201f1
......@@ -581,19 +581,26 @@ const filterAndSortRecommendations = (
showDraftRecommendationById = null
) => {
const allRecommendations = pubRecommendations.concat(workRecommendations);
const uniqueRecommendations = new Map();
const recommendationsById = new Map();
allRecommendations.forEach(recommendation => {
console.log(recommendation.created);
uniqueRecommendations.set(recommendation.id, recommendation);
recommendationsById.set(recommendation.id, recommendation);
});
const filteredRecommendations = Array.from(uniqueRecommendations.values())
const uniqueRecommendations = Array.from(recommendationsById.values());
if (showDraftRecommendationById) {
return uniqueRecommendations.filter(
rec =>
rec.id ===
`https://content.deichman.no/recommendation/${showDraftRecommendationById}`
);
}
const filteredRecommendations = uniqueRecommendations
.filter(recommendation => {
if (
(recommendation.onlyTargetPublication &&
recommendation.target.id !== publicationUri) ||
(recommendation.status === "draft" &&
recommendation.id !==
`https://content.deichman.no/recommendation/${showDraftRecommendationById}`)
recommendation.status === "draft"
) {
return false;
}
......
Markdown is supported
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