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