From 9400f1a32bf01c8b6f39c597796dbf743a97fa63 Mon Sep 17 00:00:00 2001 From: ue Date: Sat, 24 Aug 2019 14:56:14 +0300 Subject: [PATCH] changed locig for promote post listing --- src/components/posts/view/postsView.js | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/components/posts/view/postsView.js b/src/components/posts/view/postsView.js index 80eef4b8e..314def2ea 100644 --- a/src/components/posts/view/postsView.js +++ b/src/components/posts/view/postsView.js @@ -138,7 +138,7 @@ class PostsView extends Component { : PROFILE_FILTERS[selectedFilterIndex].toLowerCase(); let options; let newPosts = []; - const limit = 11; + const limit = 3; if (!isConnected) { this.setState({ @@ -203,17 +203,32 @@ class PostsView extends Component { setFeedPosts(_posts); } - if (refreshing) { - _posts = _posts.filter(item => !item.is_promoted); - } - + // Promoted post start if (promotedPosts && promotedPosts.length > 0) { - promotedPosts.forEach((promotedItem, i) => { - if (get(_posts, [(i + 1) * 3], {}).permlink !== promotedItem.permlink) { - if (_posts[i * 3]) _posts.splice((i + 1) * 3, i * 3, promotedItem); + const insert = (arr, index, newItem) => [ + ...arr.slice(0, index), + + newItem, + + ...arr.slice(index), + ]; + + if (refreshing) { + _posts = _posts.filter(item => !item.is_promoted); + } + + _posts.map((d, i) => { + if ([3, 6, 9].includes(i)) { + const ix = i / 3 - 1; + if (promotedPosts[ix] !== undefined) { + if (get(_posts, [i], {}).permlink !== promotedPosts[ix].permlink) { + _posts = insert(_posts, i, promotedPosts[ix]); + } + } } }); } + // Promoted post end if (refreshing) { this.setState({