From d98009c7d50a1349697c972ce8ceb52b1a7244ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw?= Date: Thu, 7 Sep 2023 16:33:43 +0300 Subject: [PATCH] Disable "Next" button in Paginator when the next page is empty (#2114) * Store communityLimit as a constant in the config * Block Next button on communities list if the next page is empty * Use this.props instead of undefined props, compare number to the length of the array, not the array itself * Set nextDisabled prop for Paginator in registration-applications component * Set nextDisabled prop in Paginator required * Ignore nextDisabled prop in Paginator component used in person/inbox.tsx and modlog.tsx * Set nextDisabled to true if community is not yet loaded or no more pages are expected * Set nextDisabled to false for Paginator in emojis-form.tsx * Fix swapped bool logic in community.tsx * Set nextDisabled for Paginator in home.tsx * Set nextDisabled for Comments and Posts in person-details.tsx * Set nextDisabled for reports.tsx * Set nextDisabled for search.tsx --------- Co-authored-by: SleeplessOne1917 --- src/shared/components/common/paginator.tsx | 2 ++ src/shared/components/community/communities.tsx | 11 +++++++++-- src/shared/components/community/community.tsx | 9 ++++++++- src/shared/components/home/emojis-form.tsx | 6 +++++- src/shared/components/home/home.tsx | 9 ++++++++- src/shared/components/modlog.tsx | 6 +++++- src/shared/components/person/inbox.tsx | 1 + src/shared/components/person/person-details.tsx | 11 ++++++++++- .../components/person/registration-applications.tsx | 1 + src/shared/components/person/reports.tsx | 10 ++++++++++ src/shared/components/search.tsx | 9 ++++++++- src/shared/config.ts | 4 ++++ 12 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/shared/components/common/paginator.tsx b/src/shared/components/common/paginator.tsx index ed0ed211f..b1b452b61 100644 --- a/src/shared/components/common/paginator.tsx +++ b/src/shared/components/common/paginator.tsx @@ -4,6 +4,7 @@ import { I18NextService } from "../../services"; interface PaginatorProps { page: number; onChange(val: number): any; + nextDisabled: boolean; } export class Paginator extends Component { @@ -23,6 +24,7 @@ export class Paginator extends Component { diff --git a/src/shared/components/community/communities.tsx b/src/shared/components/community/communities.tsx index 4d6a107fd..75038f569 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -32,7 +32,7 @@ import { Paginator } from "../common/paginator"; import { SortSelect } from "../common/sort-select"; import { CommunityLink } from "./community-link"; -const communityLimit = 50; +import { communityLimit } from "../../config"; type CommunitiesData = RouteDataResponse<{ listCommunitiesResponse: ListCommunitiesResponse; @@ -221,7 +221,14 @@ export class Communities extends Component { - + + this.state.listCommunitiesResponse.data.communities.length + } + /> ); } diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index b0787ecd9..02d88dfe5 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -344,7 +344,14 @@ export class Community extends Component< {this.selects(res)} {this.listings(res)} - + this.state.postsRes.data.posts.length + } + />