mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 10:52:16 +03:00
Merge pull request #962 from esteemapp/bugfix/feed-caching
Bugfix/feed caching
This commit is contained in:
commit
22371282d5
@ -1,5 +1,6 @@
|
||||
import React, { PureComponent, Fragment } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Component
|
||||
import PostsView from '../view/postsView';
|
||||
@ -53,7 +54,9 @@ class PostsContainer extends PureComponent {
|
||||
return (
|
||||
<PostsView
|
||||
handleOnScrollStart={this._handleOnScrollStart}
|
||||
currentAccountUsername={currentAccount && currentAccount.username}
|
||||
currentAccountUsername={
|
||||
currentAccount && (get(currentAccount, 'username') || get(currentAccount, 'name'))
|
||||
}
|
||||
setFeedPosts={this._setFeedPosts}
|
||||
feedPosts={feedPosts}
|
||||
isConnected={isConnected}
|
||||
|
@ -22,7 +22,7 @@ class PostsView extends Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
posts: props.feedPosts,
|
||||
posts: props.isConnected ? [] : props.feedPosts,
|
||||
startAuthor: '',
|
||||
startPermlink: '',
|
||||
refreshing: false,
|
||||
@ -178,7 +178,10 @@ class PostsView extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
setFeedPosts(_posts);
|
||||
if (posts.length < 5) {
|
||||
setFeedPosts(_posts);
|
||||
}
|
||||
|
||||
if (refreshing && newPosts.length > 0) {
|
||||
this.setState({
|
||||
posts: _posts,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import get from 'lodash/get';
|
||||
|
||||
import {
|
||||
FETCH_ACCOUNT_FAIL,
|
||||
FETCHING_ACCOUNT,
|
||||
@ -45,7 +47,11 @@ export default function(state = initialState, action) {
|
||||
case ADD_OTHER_ACCOUNT:
|
||||
return {
|
||||
...state,
|
||||
otherAccounts: [...state.otherAccounts, action.payload],
|
||||
otherAccounts: state.otherAccounts.some(
|
||||
({ username }) => username === get(action.payload, 'username'),
|
||||
)
|
||||
? [...state.otherAccounts]
|
||||
: [...state.otherAccounts, action.payload],
|
||||
isFetching: false,
|
||||
hasError: false,
|
||||
errorMessage: null,
|
||||
|
Loading…
Reference in New Issue
Block a user