mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge pull request #1058 from esteemapp/bugfix/promotePost
Bugfix/promote post
This commit is contained in:
commit
df4ea5150e
@ -161,7 +161,7 @@ class PostCardView extends Component {
|
|||||||
iconStyle={styles.commentIcon}
|
iconStyle={styles.commentIcon}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
isClickable
|
isClickable
|
||||||
text={get(content, 'vote_count', 0)}
|
text={get(content, 'children', 0)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -69,7 +69,7 @@ class PostsContainer extends PureComponent {
|
|||||||
forceLoadPost={forceLoadPost}
|
forceLoadPost={forceLoadPost}
|
||||||
getFor={getFor}
|
getFor={getFor}
|
||||||
handleOnScroll={handleOnScroll}
|
handleOnScroll={handleOnScroll}
|
||||||
hanldeImagesHide={this._handleImagesHide}
|
handleImagesHide={this._handleImagesHide}
|
||||||
hidePostsThumbnails={hidePostsThumbnails}
|
hidePostsThumbnails={hidePostsThumbnails}
|
||||||
isConnected={isConnected}
|
isConnected={isConnected}
|
||||||
isHideImage={isHideImages}
|
isHideImage={isHideImages}
|
||||||
|
@ -4,6 +4,7 @@ import { FlatList, View, ActivityIndicator, RefreshControl } from 'react-native'
|
|||||||
import { injectIntl } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
|
|
||||||
// STEEM
|
// STEEM
|
||||||
import { getPostsSummary, getPost } from '../../../providers/steem/dsteem';
|
import { getPostsSummary, getPost } from '../../../providers/steem/dsteem';
|
||||||
import { getPromotePosts } from '../../../providers/esteem/esteem';
|
import { getPromotePosts } from '../../../providers/esteem/esteem';
|
||||||
@ -94,16 +95,17 @@ class PostsView extends Component {
|
|||||||
const { currentAccountUsername } = this.props;
|
const { currentAccountUsername } = this.props;
|
||||||
|
|
||||||
await getPromotePosts().then(async res => {
|
await getPromotePosts().then(async res => {
|
||||||
const promotedPosts = [];
|
|
||||||
|
|
||||||
if (res && res.length) {
|
if (res && res.length) {
|
||||||
res.forEach(async item => {
|
const promotedPosts = await Promise.all(
|
||||||
const post = await getPost(item.author, item.permlink, currentAccountUsername, true);
|
res.map(item =>
|
||||||
promotedPosts.push(post);
|
getPost(get(item, 'author'), get(item, 'permlink'), currentAccountUsername, true).then(
|
||||||
});
|
post => post,
|
||||||
}
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
await this.setState({ promotedPosts });
|
this.setState({ promotedPosts });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ class PostsView extends Component {
|
|||||||
: PROFILE_FILTERS[selectedFilterIndex].toLowerCase();
|
: PROFILE_FILTERS[selectedFilterIndex].toLowerCase();
|
||||||
let options;
|
let options;
|
||||||
let newPosts = [];
|
let newPosts = [];
|
||||||
const limit = promotedPosts ? (promotedPosts.length >= 3 ? 9 : 6) : 3;
|
const limit = 9;
|
||||||
|
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -201,17 +203,17 @@ class PostsView extends Component {
|
|||||||
setFeedPosts(_posts);
|
setFeedPosts(_posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshing && newPosts.length > 0) {
|
if (promotedPosts && promotedPosts.length > 0) {
|
||||||
|
promotedPosts.forEach((promotedItem, i) => {
|
||||||
|
_posts.splice((i + 1) * 3, i * 3, promotedItem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refreshing) {
|
||||||
this.setState({
|
this.setState({
|
||||||
posts: _posts,
|
posts: _posts,
|
||||||
});
|
});
|
||||||
} else if (!refreshing) {
|
} else if (!refreshing) {
|
||||||
if (!startAuthor) {
|
|
||||||
promotedPosts.map((promotedItem, i) => {
|
|
||||||
_posts.splice((i + 1) * 3, i * 3, promotedItem);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
posts: _posts,
|
posts: _posts,
|
||||||
startAuthor: result[result.length - 1] && result[result.length - 1].author,
|
startAuthor: result[result.length - 1] && result[result.length - 1].author,
|
||||||
@ -236,11 +238,15 @@ class PostsView extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_handleOnRefreshPosts = () => {
|
_handleOnRefreshPosts = () => {
|
||||||
|
const { pageType } = this.props;
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
refreshing: true,
|
refreshing: true,
|
||||||
},
|
},
|
||||||
() => {
|
async () => {
|
||||||
|
if (pageType !== 'profiles') await this._getPromotePosts();
|
||||||
|
|
||||||
this._loadPosts();
|
this._loadPosts();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -345,7 +351,7 @@ class PostsView extends Component {
|
|||||||
selectedOptionIndex,
|
selectedOptionIndex,
|
||||||
isDarkTheme,
|
isDarkTheme,
|
||||||
isHideImage,
|
isHideImage,
|
||||||
hanldeImagesHide,
|
handleImagesHide,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -359,7 +365,7 @@ class PostsView extends Component {
|
|||||||
rightIconName="view-module"
|
rightIconName="view-module"
|
||||||
rightIconType="MaterialIcons"
|
rightIconType="MaterialIcons"
|
||||||
onDropdownSelect={this._handleOnDropdownSelect}
|
onDropdownSelect={this._handleOnDropdownSelect}
|
||||||
onRightIconPress={hanldeImagesHide}
|
onRightIconPress={handleImagesHide}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -369,7 +375,7 @@ class PostsView extends Component {
|
|||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<PostCard isRefresh={refreshing} content={item} isHideImage={isHideImage} />
|
<PostCard isRefresh={refreshing} content={item} isHideImage={isHideImage} />
|
||||||
)}
|
)}
|
||||||
keyExtractor={content => content.permlink}
|
keyExtractor={(content, i) => `${get(content, 'permlink', '')}${i.toString()}`}
|
||||||
onEndReached={() => this._loadPosts()}
|
onEndReached={() => this._loadPosts()}
|
||||||
removeClippedSubviews
|
removeClippedSubviews
|
||||||
refreshing={refreshing}
|
refreshing={refreshing}
|
||||||
|
Loading…
Reference in New Issue
Block a user