diff --git a/config/app.settings.js b/config/app.settings.js index 115d6469..6b442c3d 100755 --- a/config/app.settings.js +++ b/config/app.settings.js @@ -22,5 +22,5 @@ export var DevOptions = { CurrentBundle: 'light_ng', // In KB MaximunAPIPayload: '101376', - limit_post_catch: ReturnDevOption('limit_post_catch') + limit_post_catch: '20' } \ No newline at end of file diff --git a/package.json b/package.json index e62f4d6a..575b4239 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "comty-development", "title": "Comty™", "DevBuild": true, - "version": "0.2.10", + "version": "0.2.11", "description": "", "main": "index.js", "author": "RageStudio", diff --git a/src/components/MainFeed/index.js b/src/components/MainFeed/index.js index 7296774b..4c84932f 100755 --- a/src/components/MainFeed/index.js +++ b/src/components/MainFeed/index.js @@ -2,12 +2,11 @@ import React from 'react' import * as antd from 'antd' import * as ycore from 'ycore' -import InfiniteScroll from 'react-infinite-scroller'; - import {PostCard} from 'components' var userData = ycore.SDCP() + export function RefreshFeed(){ ycore.yconsole.log('Refreshing Feed...') window.MainFeedComponent.handleRefreshList(); @@ -18,132 +17,127 @@ class MainFeed extends React.Component { super(props) window.MainFeedComponent = this; this.state = { - feedRaw: [], - loading: true, - hasMore: true, + loading: false, + data: [], + fkey: 0 } } + handleRefreshList(){ + this.GetPostsData.first() + } toogleLoader(){ this.setState({ loading: !this.state.loading }) } - - GetPostsData(fkey){ - const { get, uid, filters } = this.props; - if (!get) { - ycore.yconsole.error('Please, fill params with an catch type...') - return - } - if (!fkey) { - ycore.yconsole.warn('Please, provide a fkey for offset the feed, default using => 0'); - - } - this.toogleLoader() - ycore.GetPosts(uid, get, (fkey || '0'), (err, result) => { - this.setState({ feedRaw: result, loading: false }) - }) + last (array, n) { + if (array == null) + return void 0; + if (n == null) + return array[array.length - 1]; + return array.slice(Math.max(array.length - n, 0)); + }; + FirstGet(fkey) { + try{ + const { get, uid, filters } = this.props; + if (!get) { + ycore.yconsole.error('Please, fill params with an catch type...') + return + } + + this.toogleLoader() + ycore.GetPosts(uid, get, '0', (err, result) => { + this.setState({ data: JSON.parse(result)['data'], loading: false }) + }) + }catch(err){ + ycore.notifyError('err') + } } + GetMore(fkey){ + try{ + const { get, uid, filters } = this.props; + if (!get) { + ycore.yconsole.error('Please, fill params with an catch type...') + return + } + if (!fkey) { + ycore.yconsole.warn('Please, provide a fkey for offset the feed, default using => 0'); + } + this.toogleLoader() + const getLastPost = this.last(this.state.data) + ycore.yconsole.log('LAST POST ID =>', getLastPost.id) + ycore.GetPosts(uid, get, getLastPost.id, (err, res) => { + if (err){return false} + + const oldData = this.state.data + const parsed = JSON.parse(res)['data'] + const mix = oldData.concat(parsed) + + this.setState({ data: mix, loading: false }) + window.dispatchEvent(new Event('resize')); + return true + + }) + + + }catch(err){ + ycore.notifyError(err) + } + + } + + componentDidMount(){ - this.GetPostsData() - + this.FirstGet() } - renderFeedPosts = (e) =>{ - const {feedRaw} = this.state - const { get, filters } = this.props + + renderFeedPosts = () =>{ + const {data, loading} = this.state + const loadMore = + !loading ? ( +