MOBILE-3039 forum: Fix attachments not downloaded on prefetch

main
Dani Palou 2019-06-04 12:12:15 +02:00
parent f719d8e9b1
commit a3d88eba4e
1 changed files with 18 additions and 1 deletions

View File

@ -122,7 +122,24 @@ export class AddonModForumPrefetchHandler extends CoreCourseActivityPrefetchHand
}); });
}); });
return Promise.all(promises); return Promise.all(promises).then((results) => {
// Each order has returned its own list of posts. Merge all the lists, preventing duplicates.
const posts = [],
postIds = {}; // To make the array unique.
results.forEach((orderResults) => {
orderResults.forEach((orderResult) => {
orderResult.posts.forEach((post) => {
if (!postIds[post.id]) {
postIds[post.id] = true;
posts.push(post);
}
});
});
});
return posts;
});
} }
/** /**