]> Untitled Git - lemmy.git/commitdiff
Hide next paginator.
authorDessalines <tyhou13@gmx.com>
Sun, 19 Jan 2020 21:47:54 +0000 (16:47 -0500)
committerDessalines <tyhou13@gmx.com>
Sun, 19 Jan 2020 21:47:54 +0000 (16:47 -0500)
- Fixes #441
- Hide post sort radio if no comments.

ui/src/components/communities.tsx
ui/src/components/community.tsx
ui/src/components/main.tsx
ui/src/components/post.tsx

index 7e4a0ef8b973ecd2027dc596a6337cb37da07e55..598a5dad63bffc20f4c81dcda76702d81f164cf6 100644 (file)
@@ -18,6 +18,8 @@ import { T } from 'inferno-i18next';
 
 declare const Sortable: any;
 
+const communityLimit = 100;
+
 interface CommunitiesState {
   communities: Array<Community>;
   page: number;
@@ -36,14 +38,7 @@ export class Communities extends Component<any, CommunitiesState> {
     super(props, context);
     this.state = this.emptyState;
     this.subscription = WebSocketService.Instance.subject
-      .pipe(
-        retryWhen(errors =>
-          errors.pipe(
-            delay(3000),
-            take(10)
-          )
-        )
-      )
+      .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
       .subscribe(
         msg => this.parseMessage(msg),
         err => console.error(err),
@@ -180,12 +175,14 @@ export class Communities extends Component<any, CommunitiesState> {
             <T i18nKey="prev">#</T>
           </button>
         )}
-        <button
-          class="btn btn-sm btn-secondary"
-          onClick={linkEvent(this, this.nextPage)}
-        >
-          <T i18nKey="next">#</T>
-        </button>
+        {this.state.communities.length == communityLimit && (
+          <button
+            class="btn btn-sm btn-secondary"
+            onClick={linkEvent(this, this.nextPage)}
+          >
+            <T i18nKey="next">#</T>
+          </button>
+        )}
       </div>
     );
   }
@@ -227,7 +224,7 @@ export class Communities extends Component<any, CommunitiesState> {
   refetch() {
     let listCommunitiesForm: ListCommunitiesForm = {
       sort: SortType[SortType.TopAll],
-      limit: 100,
+      limit: communityLimit,
       page: this.state.page,
     };
 
index 6bcd88b1d03f74f68dfa14aa82e814be5a768e94..03766bdcd4c22c56b5122e13a451de1bc6c953c6 100644 (file)
@@ -192,12 +192,14 @@ export class Community extends Component<any, State> {
             <T i18nKey="prev">#</T>
           </button>
         )}
-        <button
-          class="btn btn-sm btn-secondary"
-          onClick={linkEvent(this, this.nextPage)}
-        >
-          <T i18nKey="next">#</T>
-        </button>
+        {this.state.posts.length == fetchLimit && (
+          <button
+            class="btn btn-sm btn-secondary"
+            onClick={linkEvent(this, this.nextPage)}
+          >
+            <T i18nKey="next">#</T>
+          </button>
+        )}
       </div>
     );
   }
index 9e7d690dcf9d6358a5a8ef113dafc5d32251fe77..95eeb1df54f101f7d71bcb9aa71c6dc0279c3f6e 100644 (file)
@@ -480,12 +480,14 @@ export class Main extends Component<any, MainState> {
             <T i18nKey="prev">#</T>
           </button>
         )}
-        <button
-          class="btn btn-sm btn-secondary"
-          onClick={linkEvent(this, this.nextPage)}
-        >
-          <T i18nKey="next">#</T>
-        </button>
+        {this.state.posts.length == fetchLimit && (
+          <button
+            class="btn btn-sm btn-secondary"
+            onClick={linkEvent(this, this.nextPage)}
+          >
+            <T i18nKey="next">#</T>
+          </button>
+        )}
       </div>
     );
   }
index d486938660ebd94759584289d6c924769890abcc..c4bfccee184de8ea0fe76b4a6c99015d3b92a546 100644 (file)
@@ -178,7 +178,7 @@ export class Post extends Component<any, PostState> {
                 postId={this.state.post.id}
                 disabled={this.state.post.locked}
               />
-              {this.sortRadios()}
+              {this.state.comments.length > 0 && this.sortRadios()}
               {this.commentsTree()}
             </div>
             <div class="col-12 col-sm-12 col-md-4">