mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 21:35:04 +03:00
WIP: get more replies and comments on profile page
This commit is contained in:
parent
75ac107e46
commit
3e5b73816c
@ -43,6 +43,17 @@ class ProfileView extends PureComponent {
|
||||
}
|
||||
};
|
||||
|
||||
_loadMoreComments = () => {
|
||||
const { getReplies, comments } = this.props;
|
||||
|
||||
if (comments && comments.length > 0) {
|
||||
getReplies({
|
||||
author: comments[comments.length - 1].author,
|
||||
permlink: comments[comments.length - 1].permlink,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_handleOnSummaryExpanded = () => {
|
||||
const { isSummaryOpen } = this.state;
|
||||
|
||||
@ -55,6 +66,10 @@ class ProfileView extends PureComponent {
|
||||
this.setState({ collapsibleMoreHeight: height });
|
||||
};
|
||||
|
||||
_isCloseToBottom({ layoutMeasurement, contentOffset, contentSize }) {
|
||||
return layoutMeasurement.height + contentOffset.y >= contentSize.height - 20;
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
about,
|
||||
@ -198,9 +213,14 @@ class ProfileView extends PureComponent {
|
||||
>
|
||||
{comments && comments.length > 0 ? (
|
||||
<ScrollView
|
||||
onScroll={this._handleOnScroll}
|
||||
onScroll={({ nativeEvent }) => {
|
||||
this._handleOnScroll();
|
||||
if (this._isCloseToBottom(nativeEvent)) {
|
||||
this._loadMoreComments();
|
||||
}
|
||||
}}
|
||||
contentContainerStyle={styles.scrollContentContainer}
|
||||
scrollEventThrottle={16}
|
||||
//scrollEventThrottle={16}
|
||||
>
|
||||
<Comments
|
||||
isProfilePreview
|
||||
|
@ -76,7 +76,7 @@ class ProfileContainer extends Component {
|
||||
this._loadProfile(targetUsername);
|
||||
}
|
||||
|
||||
_getReplies = async user => {
|
||||
_getReplies = async query => {
|
||||
const { isOwnProfile } = this.state;
|
||||
let repliesAction;
|
||||
|
||||
@ -86,7 +86,11 @@ class ProfileContainer extends Component {
|
||||
repliesAction = getRepliesByLastUpdate;
|
||||
}
|
||||
|
||||
await repliesAction({ start_author: user, limit: 10 }).then(result => {
|
||||
await repliesAction({
|
||||
start_author: query.author,
|
||||
start_permlink: query.permlink,
|
||||
limit: 10,
|
||||
}).then(result => {
|
||||
this.setState({
|
||||
comments: result,
|
||||
});
|
||||
@ -229,7 +233,7 @@ class ProfileContainer extends Component {
|
||||
username,
|
||||
}));
|
||||
|
||||
this._getReplies(username);
|
||||
this._getReplies({ author: username, permlink: undefined });
|
||||
};
|
||||
|
||||
_handleFollowsPress = async isFollowingPress => {
|
||||
@ -364,7 +368,7 @@ class ProfileContainer extends Component {
|
||||
error,
|
||||
follows,
|
||||
forceLoadPost,
|
||||
getReplies: () => this._getReplies(username),
|
||||
getReplies: this._getReplies,
|
||||
handleFollowUnfollowUser: this._handleFollowUnfollowUser,
|
||||
handleMuteUnmuteUser: this._handleMuteUnmuteUser,
|
||||
handleOnBackPress: this._handleOnBackPress,
|
||||
|
Loading…
Reference in New Issue
Block a user