diff --git a/script.js b/script.js index 37a2d0c..af565e5 100644 --- a/script.js +++ b/script.js @@ -132,8 +132,6 @@ const displayPost = function(post) { const processPosts = function(posts) { posts = posts.filter((post) => secondsAgo(new Date(post.created_at)) < maxAge); - posts.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)); - return posts; }; @@ -143,6 +141,8 @@ const updateWall = function(posts) { posts = processPosts(posts); + posts.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)); + let ret = 0 posts.forEach(post => ret += displayPost(post)); $('.masonry-grid').masonry('layout'); @@ -155,7 +155,9 @@ const updateCarousel = function(slides, posts) { if (!posts || posts.length === 0) return; posts = processPosts(posts); - + + posts.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); + // remove slides in carousel slides.innerHTML = ""; var newHTML = ` `