Skip to content

Commit

Permalink
only 1 latest info render instead of all in view
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgiMagic committed Aug 14, 2023
1 parent 27a4475 commit 14a32c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/render/contentRendering.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const renderNewPosts = (elements, posts) => {
posts.at(-1).reverse().forEach(({ element }) => {
posts.reverse().forEach(({ element }) => {
elements.postsUL.prepend(element);
});
};

const renderNewFeed = (elements, feeds) => {
elements.feedsUL.prepend(feeds.at(-1));
const renderNewFeed = (elements, feed) => {
elements.feedsUL.prepend(feed);
};

export { renderNewPosts, renderNewFeed };
4 changes: 2 additions & 2 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const createWatchedState = (elements, state, i18) => onChange(state, (path, valu
}

if (path === 'posts') {
const htmlPosts = state.posts.map((posts) => renderPosts(posts, i18));
const htmlPosts = renderPosts(state.posts.at(-1), i18);
renderNewPosts(elements, htmlPosts);
}

Expand All @@ -28,7 +28,7 @@ const createWatchedState = (elements, state, i18) => onChange(state, (path, valu
document.querySelector('.posts').classList.remove('invisible');
}

const htmlFeeds = state.feeds.map((feed) => renderFeed(feed));
const htmlFeeds = renderFeed(state.feeds.at(-1));
renderNewFeed(elements, htmlFeeds);
}

Expand Down

0 comments on commit 14a32c9

Please sign in to comment.