diff --git a/src/components/posts/container/postsContainer.js b/src/components/posts/container/postsContainer.js index 821a28ecc..10247ce05 100644 --- a/src/components/posts/container/postsContainer.js +++ b/src/components/posts/container/postsContainer.js @@ -9,7 +9,6 @@ import { PostCardPlaceHolder } from '../../basicUIElements'; // Actions import { isCollapsePostButton } from '../../../redux/actions/uiAction'; import { setFeedPosts } from '../../../redux/actions/postsAction'; -import { getPromotePosts } from '../../../providers/esteem/esteem'; /* * Props Name Description Value *@props --> props name here description here Value Type Here @@ -20,25 +19,14 @@ class PostsContainer extends PureComponent { constructor(props) { super(props); this.state = { - promotePosts: [], + promotedPosts: [], }; } // Component Life Cycle Functions - componentDidMount() { - this._getPromotePosts(); - } - // Component Functions - _getPromotePosts = () => { - getPromotePosts().then(res => { - this.setState({ promotePosts: res }); - console.log(res); - }); - }; - _handleOnScrollStart = () => { const { dispatch, isCollapsePostButtonOpen } = this.props; @@ -55,7 +43,7 @@ class PostsContainer extends PureComponent { render() { const { currentAccount, isLoginDone, tag, feedPosts, isConnected } = this.props; - const { promotePosts } = this.state; + const { promotedPosts } = this.state; if (!isLoginDone && !tag) { return ( @@ -68,7 +56,7 @@ class PostsContainer extends PureComponent { return ( { + const { currentAccountUsername } = this.props; + await getPromotePosts().then(async res => { + const promotedPosts = []; + res && + res.length > 0 && + res.map(async item => { + const post = await getPost(item.author, item.permlink, currentAccountUsername); + promotedPosts.push(post); + }); + + await this.setState({ promotedPosts }); + }); + }; + _scrollToTop = () => { if (this.flatList) this.flatList.scrollToOffset({ x: 0, y: 0, animated: true }); }; - _loadPosts = () => { + _loadPosts = async () => { const { getFor, tag, @@ -110,6 +130,7 @@ class PostsView extends Component { refreshing, selectedFilterIndex, isLoading, + promotedPosts, } = this.state; const filter = pageType === 'posts' @@ -157,6 +178,7 @@ class PostsView extends Component { .then(result => { if (result.length > 0) { let _posts = result; + console.log(promotedPosts); if (filter === 'reblogs') { for (let i = _posts.length - 1; i >= 0; i--) { @@ -178,6 +200,20 @@ class PostsView extends Component { } } + // result && + // result.length > 0 && + // result.map((item, i) => { + // if ([3, 6, 9].includes(i)) { + // const ix = i / 3 - 1; + // if (promotedPosts[ix] !== undefined) { + // const p = promotedPosts[ix]; + + // _posts.push(p); + // } + // } + // }); + _posts = promotedPosts; + if (posts.length < 5) { setFeedPosts(_posts); } diff --git a/src/config/api.js b/src/config/api.js index 704e22742..8a8ddbf80 100644 --- a/src/config/api.js +++ b/src/config/api.js @@ -5,6 +5,7 @@ const api = axios.create({ baseURL: Config.BACKEND_URL, headers: { 'Content-Type': 'application/json', + 'User-Agent': Config.USER_AGENT, }, }); diff --git a/src/config/ePoint.js b/src/config/ePoint.js deleted file mode 100644 index a180ed5a2..000000000 --- a/src/config/ePoint.js +++ /dev/null @@ -1,11 +0,0 @@ -import axios from 'axios'; -import Config from 'react-native-config'; - -const ePoint = axios.create({ - baseURL: Config.BACKEND_URL, - headers: { - 'User-Agent': Config.USER_AGENT, - }, -}); - -export default ePoint; diff --git a/src/providers/esteem/ePoint.js b/src/providers/esteem/ePoint.js index 33c6ca677..aa3e9ca70 100644 --- a/src/providers/esteem/ePoint.js +++ b/src/providers/esteem/ePoint.js @@ -1,5 +1,5 @@ import { Alert } from 'react-native'; -import ePointApi from '../../config/ePoint'; +import ePointApi from '../../config/api'; export const userActivity = (us, ty, bl = '', tx = '') => new Promise(resolve => {