From 9e42ccb82dcab1c86f048e6bbc8df11f4759169b Mon Sep 17 00:00:00 2001
From: Renard
Date: Mon, 23 Sep 2019 12:49:59 -0300
Subject: Infinite scroll fix

---
 src/Board.js | 21 ++++++++++++++++++---
 1 file 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>
     );
   }
-- 
cgit v1.2.1-18-gbd029