Skip to content

Commit

Permalink
IMAEGEDAM-1982: Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Conalb97 committed Oct 15, 2024
1 parent 46a4c0b commit 4205430
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions kahuna/public/js/search/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,38 +399,28 @@ results.controller('SearchResultsCtrl', [
globalErrors.trigger('clipboard', sharedUrl);
};

const imageHasSyndicationUsage = (image) => {
return image.data.usages.data.some(usage =>
usage.data.platform === 'syndication'
);
};

const validatePhotoSalesSelection = (images) => {
const validImages = [];
const invalidImages = [];

const filteredImages = images
.filter(image => {
if (image.data.uploadedBy === "Capture_AutoIngest") {
invalidImages.push(image);
return false;
}
return true;
})
.filter(image => {
if (image.data.usages.data.length === 0) {
validImages.push(image);
return false;
}
return true;
});
filteredImages.forEach((image) => {
let syndicationExists = false;
for (const usage of image.data.usages.data) {
if (usage.data.platform === "syndication") {
syndicationExists = true;
break;
}
images.forEach(image => {
if (image.data.uploadedBy === 'Capture_AutoIngest' || imageHasSyndicationUsage(image)) {
invalidImages.push(image);
} else {
validImages.push(image);
}
(syndicationExists === true ? invalidImages : validImages).push(image);
});

return [validImages, invalidImages];
};


ctrl.showPaid = undefined;
mediaApi.getSession().then(session => {
ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined;
Expand Down

0 comments on commit 4205430

Please sign in to comment.