in public/js/actions/AtomActions/getSuggestionsForLatestContent.js [123:151]
export function getSuggestionsForLatestContent() {
return dispatch => {
dispatch(requestSuggestionsForLatestContent());
return mostViewed()
.then(mostViewedContent =>
Promise.all(mostViewedContent.map(content => getTagsForContent(content.url.slice(skipChars))))
)
//Filter out any articles that already contain a snippet atom
.then(contentArray => contentArray.filter(content => !content.atoms || content.atoms.length === 0))
.then(contentArray => {
const tags = getTags(contentArray);
const targetsPromise = getTargets(tags);
const urlToAtomPromise = targetsPromise.then(getAtomUrlToAtom);
return Promise.all([targetsPromise, urlToAtomPromise])
.then(([targets, urlToAtom]) => {
const tagToUrls = getTagToUrls(targets);
return resolveContentAtoms(contentArray, tagToUrls, urlToAtom);
});
})
.then(results => dispatch(receiveSuggestionsForLatestContent(results)))
.catch(error => {
dispatch(errorReceivingSuggestionsForLatestContent(error));
});
};
}