1
0
mirror of https://github.com/hyperspacedev/hyperspace synced 2025-02-07 15:28:40 +01:00

Check that posts's length is greater than 0 before running (fix #13)

This commit is contained in:
Marquis Kurt 2019-04-24 14:29:33 -04:00
parent 5a785c50c8
commit 63a9a5d7d9

View File

@ -122,7 +122,7 @@ class ProfilePage extends Component<any, IProfilePageState> {
loadMoreTimelinePieces() {
const { match: {params}} = this.props;
this.setState({ viewDidLoad: false, viewIsLoading: true})
if (this.state.posts) {
if (this.state.posts && this.state.posts.length > 0) {
this.client.get(`/accounts/${params.profileId}/statuses`, { max_id: this.state.posts[this.state.posts.length - 1].id, limit: 20 }).then((resp: any) => {
let newPosts: [Status] = resp.data;
let posts = this.state.posts as [Status];
@ -150,6 +150,8 @@ class ProfilePage extends Component<any, IProfilePageState> {
variant: 'error',
});
})
} else {
this.props.enqueueSnackbar("Reached end of posts", { variant: 'error'} );
}
}