aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Board.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Board.js b/src/Board.js
index 5dd00a2..41727bc 100644
--- a/src/Board.js
+++ b/src/Board.js
@@ -17,7 +17,8 @@ class Board extends Component {
isLoaded: false,
threadList: [],
error: null,
- loadingMore: false
+ loadingMore: false,
+ endReached: false
};
this.handleScroll = this.handleScroll.bind(this);
this.threadOffset = 10;
@@ -46,7 +47,11 @@ class Board extends Component {
handleScroll() {
const { scrollHeight, scrollTop, clientHeight } = document.documentElement;
- if (scrollHeight - scrollTop === clientHeight && !this.state.loadingMore) {
+ if (
+ scrollHeight - scrollTop === clientHeight &&
+ !this.state.loadingMore &&
+ !this.state.endReached
+ ) {
this.setState({ loadingMore: true });
this.fetchMoreThreads();
}
@@ -65,6 +70,8 @@ class Board extends Component {
const moreThreads = this.state.threadList.concat(resource.threads);
this.threadOffset += 10;
this.setState({ threadList: moreThreads, loadingMore: false });
+ } else {
+ this.setState({ endReached: true, loadingMore: false });
}
}
return;
@@ -84,7 +91,7 @@ class Board extends Component {
}
render() {
- const { isLoaded, error, threadList, loadingMore } = this.state;
+ const { isLoaded, error, threadList, loadingMore, endReached } = this.state;
if (error != null) {
return (
@@ -162,6 +169,14 @@ class Board extends Component {
Cargando más hilos ...
</Loader>
) : null}
+
+ {endReached ? (
+ <Message
+ warning
+ header="キタ━━━(゚∀゚)━━━!!"
+ content="No hay más hilos para mostrar."
+ />
+ ) : null}
</React.Fragment>
);
}